GstRTMPMetadata examples Using gst-launch

From RidgeRun Developer Wiki

Follow Us On Twitter LinkedIn Email Share this page






NVIDIA partner logo NXP partner logo




Inserting metadata

This subsection presents sample pipelines to insert and extract arbitrary metadata over RTMP/FLV using the patched flvmux / flvdemux. The metadata is carried inside FLV Script Data tags and can be injected via properties (e.g., meta-string) or binary payloads (meta-binary). Extraction can attach a GstMeta to outgoing buffers and/or emit a signal with the payload.

Step 1 – Start a local RTMP server

You can quickly spin up a local RTMP server using SRS:

docker run --rm -p 1935:1935 ossrs/srs

Step 2 – Run the sender pipeline (insertion)

The following sender pipeline encodes a color bar test source (H.264) and injects the metadata string "Hello RTMP Metadata" into the FLV stream via flvmux meta-string=.... Finally, it pushes the stream to the local RTMP server.

gst-launch-1.0 -e \
  videotestsrc is-live=true pattern=smpte ! video/x-raw,framerate=30/1 ! \
  x264enc tune=zerolatency speed-preset=ultrafast key-int-max=60 byte-stream=false ! \
  video/x-h264,stream-format=avc,alignment=au ! \
  flvmux name=mux streamable=true meta-string="Hello RTMP Metadata" ! \
  rtmpsink location="rtmp://127.0.0.1/live/test"

Step 3 – Run the receiver pipeline (extraction)

On the receiver side, the following pipeline pulls the RTMP stream, demuxes FLV, and enables both:

  • attach-flvmeta=true – attaches the extracted metadata as a GstMeta on outgoing buffers, and
  • flv-meta-signal=true – emits a signal with the payload as GBytes for immediate application handling.
GST_DEBUG=flv*:6,flvdemux:6,gstflv*:6 \
gst-launch-1.0 -m \
  rtmpsrc location="rtmp://127.0.0.1/live/test" ! \
  flvdemux attach-flvmeta=true flv-meta-signal=true name=d \
    d.video ! identity silent=false ! fakesink sync=false \
    d.audio ! fakesink sync=false

Step 4 – Check the output

In the console you should observe bus messages and debug logs from flvdemux indicating that metadata Script Data has been parsed. When flv-meta-signal=true is set, the element emits a flv-meta signal carrying the metadata payload as GBytes. When attach-flvmeta=true is set, the first audio/video buffers downstream include a custom GstMeta with the same payload.

0:00:00.468534452 121718 0x55a34b45a8c0 INFO                flvdemux gstflvdemux.c:499:gst_flv_demux_parse_metadata_item:<d> Meta-string: Hello RTMP Metadata
Notes
  • You can inject metadata multiple times by setting meta-string more than once during streaming.
  • For binary payloads (e.g., structured blobs), use meta-binary instead of meta-string on flvmux.
  • This support is provided as patches to flvmux and flvdemux and is available for GStreamer 1.16.x, 1.20.x, and 1.24.x.

Troubleshooting

  • If you do not see metadata logs on the receiver:
    • Ensure the sender used meta-string/meta-binary on flvmux.
    • Verify caps: video/x-h264, stream-format=avc, alignment=au before flvmux.
    • Increase debug: GST_DEBUG=flv*:6,flvdemux:6,gstflv*:6 -m.
  • On headless systems, use fakesink or identity silent=false branches to inspect buffer flow.
  • If your RTMP server requires a different app/stream path, adjust rtmpsink location=rtmp://<host>/<app>/<stream>.