2025-04-05 16:52:04 +03:00
2024-06-24 11:55:56 +03:00
2024-06-24 11:55:56 +03:00
2024-06-24 11:55:56 +03:00
2024-06-24 11:55:56 +03:00
2024-06-24 11:55:56 +03:00
2024-06-24 11:55:56 +03:00
2024-06-24 11:55:56 +03:00
2025-04-05 16:52:04 +03:00

GStreamer Microsecond Timestamp Overlay

This is an adaptation of the clockoverlay and timeoverlay plugins from gstreamer-base. Stripped bare and just overlaying the Linux epoch time, with a microsecond resolution.

Use-case Examples

A single stream solution can be tested like this:

gst-launch-1.0 \
    videotestsrc is-live=true do-timestamp=true \
    ! msoverlay halignment=left valignment=top \
    ! video/x-raw,format=RGB,framerate=30/1,width=640,height=480 \
    ! videoconvert \
    ! video/x-raw,format=NV12 \
    ! nvautogpuh264enc tune=3 \
    ! rtph264pay config-interval=0 pt=96 \
    ! rtph264depay \
    ! h264parse \
    ! nvh264dec \
    ! msoverlay halignment=left valignment=bottom \
    ! autovideosink

Take a screenshot of the output above and subtract the top-left number from the bottom-left to see the total pipeline latency.

For a more comprehensive solution we can also make the stream traverse the network stack:

Server:

gst-launch-1.0 videotestsrc is-live=true do-timestamp=true ! msoverlay halignment=left valignment=top ! video/x-raw,format=RGB,framerate=60/1,width=1920,height=1080 ! videoconvert ! video/x-raw,format=NV12 ! nvautogpuh264enc tune=3 ! rtph264pay config-interval=1 pt=96 ! rtpsink uri=rtp://127.0.0.1:5000

Live client:

gst-launch-1.0 rtpsrc uri=rtp://127.0.0.1:5000?encoding-name=H264 ! rtph264depay ! h264parse ! nvh264dec ! msoverlay halignment=left valignment=bottom ! autovideosink

PNG sampling client outputting 5 frames, one per second:

gst-launch-1.0 rtpsrc uri=rtp://127.0.0.1:5000?encoding-name=H264 ! rtph264depay ! h264parse ! nvh264dec ! msoverlay halignment=left valignment=bottom ! videorate drop-only=true ! video/x-raw,framerate=1/1 ! pngenc ! multifilesink num-buffers=10 location="latency_%02d.png"

It is essential both the client and server run on the same machine, unless you really trust your system clock accuracy.

Dependencies

TODO. Basically the same dependencies as for building the gstreamer-plugins-base packages.

Building

# Assuming you're in the project root

# Option A is to use the submodule to fetch the GStreamer sources:
git submodule update --init --recursive

# Older versions require deleting the builddir and omitting the '--reconfigure' option
meson setup --reconfigure builddir
# Option B is to use an existing GStreamer source by specifying the 'gst_root' (the GStreamer mono-repo root)
# meson setup --reconfigure builddir -Dgst_root=${WHERE_I_CLONED_GSTREAMER}/gstreamer

meson compile -C builddir

# This will install the built plugin file
meson install -C builddir

# Confirm installation
gst-inspect-1.0 | grep msoverlay

Verification

This should show you a fairly extensive list of options and details:

gst-inspect-1.0 msoverlay

Author & License

LGPL-2.1 or whatever newer license GStreamer uses. Please see the LICENSE file for the full text.

Please see the upstream project for a full list of authors, at:

https://gitlab.freedesktop.org/gstreamer/gstreamer

Modifications done specific to this plugin by Stefan Hamminga stefan@rbts.co / rbts.co.

Repository

The project can be found here:

https://git.rbts.co/rbts.co/gstreamer-ms-overlay

Description
GStreamer Microsecond Timestamp Overlay
Readme LGPL-2.1 50 KiB
Languages
C 77.9%
Meson 22.1%