Working end-to-end example workflows for gstklvplugin. The focus is on reproducible pipelines rather than minimal snippets.
examples/
├── test_93_tags.py Local 93-tag roundtrip validation
├── setup-env.sh Optional shell environment helper
├── srt-pipelines/
│ ├── python/
│ │ ├── srt_sender_93tags.py SRT sender — Python
│ │ └── srt_receiver_93tags.py SRT receiver — Python
│ └── cpp/
│ ├── srt_sender_93tags.cpp SRT sender — C++
│ └── srt_receiver_93tags.cpp SRT receiver — C++
├── udp-pipelines/
│ ├── python/
│ │ ├── udp_sender_93tags.py UDP sender — Python
│ │ └── udp_receiver_93tags.py UDP receiver — Python
│ └── cpp/
│ ├── udp_sender_93tags.cpp UDP sender — C++
│ └── udp_receiver_93tags.cpp UDP receiver — C++
└── ts/
├── python/
│ ├── klv_recorder.py File-based TS recorder — Python
│ └── klv_video_reader.py File-based TS reader — Python
├── cpp/
│ ├── ts_recorder_93tags.cpp File-based TS recorder — C++
│ └── ts_video_reader_93tags.cpp File-based TS reader — C++
└── recordings/ Output directory for .ts captures
examples/test_93_tags.py
Validates the full JSON -> KLV -> JSON roundtrip for all 93 MISB ST 0601.8 tags using klvmetaenc and klvmetadec.
export GST_PLUGIN_PATH="$PWD/build/src:$GST_PLUGIN_PATH"
python3 examples/test_93_tags.pyReceiver first:
python3 examples/srt-pipelines/python/srt_receiver_93tags.py \
--host 127.0.0.1 --port 5000Then sender:
python3 examples/srt-pipelines/python/srt_sender_93tags.py \
--host 0.0.0.0 --port 5000 --count 50Important transport details:
- Sender uses
mpegtsmux alignment=7. - Sender uses
srtsink latency=125 sync=false async=false wait-for-connection=false. - Receiver uses
srtsrc blocksize=1316 latency=125. - Receiver keeps the video sink and KLV handoff sink clocked, so printed tags follow the displayed frame.
--print-summaryis the best live-inspection mode when you care about visual sync.
That combination is what made live H.264 video decode reliably while still receiving KLV.
cmake -S . -B build -DGSTKLVPLUGIN_BUILD_EXAMPLES=ON
cmake --build buildThese binaries are currently produced by CMake. Meson remains the primary build for the plugin and tests, but it does not generate the C++ examples.
Receiver first:
./build/gstklv_srt_receiver --host 127.0.0.1 --port 5000Then sender:
./build/gstklv_srt_sender --host 0.0.0.0 --port 5000 --count 50The C++ SRT examples now mirror the same transport tuning as the Python ones: alignment=7 on mpegtsmux, blocksize=1316 on srtsrc, explicit H.264 parser/decoder, and clock-synchronised KLV printing on the receiver side.
Receiver first:
python3 examples/udp-pipelines/python/udp_receiver_93tags.py \
--host 0.0.0.0 --port 5000Then sender:
python3 examples/udp-pipelines/python/udp_sender_93tags.py \
--host 127.0.0.1 --port 5000 --count 50The UDP examples are transport-equivalent to the SRT ones, but use udpsink/udpsrc instead of srtsink/srtsrc. The receivers use the same clock-synchronised print path.
Receiver first:
./build/gstklv_udp_receiver --host 0.0.0.0 --port 5000Then sender:
./build/gstklv_udp_sender --host 127.0.0.1 --port 5000 --count 50The new C++ UDP examples follow the same JSON generation, PMT rewrite, KLV decoding flow, and presentation-timed receiver output as the SRT C++ examples.
Record a .ts file with KLV:
python3 examples/ts/python/klv_recorder.py \
--output examples/ts/recordings/capture.ts --count 50Read it back:
python3 examples/ts/python/klv_video_reader.py \
examples/ts/recordings/capture.ts --print-allThe file reader accepts both stream_type 0x15 captures and the current repo behavior of 0x06 + KLVA, and paces KLV output against playback instead of dumping metadata immediately.
cmake --build build --target gstklv_ts_recorder gstklv_ts_readerRecord:
./build/gstklv_ts_recorder \
--output examples/ts/recordings/capture.ts --count 50Read:
./build/gstklv_ts_reader \
--input examples/ts/recordings/capture.ts --print-allThe C++ TS reader now scans the TS file PMT/PES directly for KLV, restores the UL prefix when needed, and paces metadata from PES PTS by default. Use --no-pace only when you want a fast metadata dump.
On some X11 sinks the C++ reader may keep the window open after the last frame has been shown. For scripted runs, wrap it with timeout; for interactive inspection, stop it with Ctrl+C after the final frame.
| Parameter | Applies to | Description |
|---|---|---|
--host |
SRT/UDP examples | Network endpoint host or bind address |
--port |
SRT/UDP examples | Transport port number |
--count |
Sender examples | Frames to send (0 = infinite) |
--output |
Receiver/reader examples | Output file path |
--print-all |
Receiver/reader examples | Print all tags every frame |
--video-sink |
C++ readers/receivers | Force a specific video sink |
Run --help on any script or executable for the full option list.
python3 tools/capture_ts_from_srt.py \
--host 127.0.0.1 --port 5000 \
--output examples/ts/recordings/capture.ts --duration 5
python3 tools/verify_ts_klv.py examples/ts/recordings/capture.ts --list-allExpected with the current repo:
- KLV PID uses
stream_type 0x06 registration_descriptor: KLVAmetadata_descriptor: present
verify_ts_klv.py also accepts legacy 0x15 captures.