GstRTMPMetadata User Guide
The GstRTMPMetadata documentation from RidgeRun is presently being developed. |
Adding FLV metadata support to your application involves two main tasks:
on the sending side, injecting metadata into the FLV stream using the muxer, and
on the receiving side, extracting metadata from the demuxer.
In this section, we will review how to achieve this using RidgeRun’s patched FLV muxer and demuxer elements.
To inject metadata it is possible to use the flvmux element patched by RidgeRun, which after applying the patches, is able to serialize and embed structured metadata (with keys starting with meta-*) into the FLV stream.
To extract metadata it is possible to use the flvdemux element patched by RidgeRun, which decodes the onMetaData message and makes the metadata available as GstMeta attached to the output buffers when the property attach-flvmeta is enabled.
FlvMux element
The expected output of running
gst-inspect-1.0 flvmux
is the following:
Factory Details: Rank primary (256) Long-name FLV muxer Klass Codec/Muxer Description Muxes video/audio streams into a FLV stream Author Sebastian Dröge <sebastian.droege@collabora.co.uk> Plugin Details: Name flv Description FLV muxing and demuxing plugin Filename /home/jsantamaria/work/rnd/1.20/001/gstreamer/builddir/subprojects/gst-plugins-good/gst/flv/libgstflv.so Version 1.20.7.1 License LGPL Source module gst-plugins-good Binary package GStreamer Good Plug-ins git Origin URL Unknown package origin GObject +----GInitiallyUnowned +----GstObject +----GstElement +----GstAggregator +----GstFlvMux Implemented Interfaces: GstTagSetter Pad Templates: SINK template: 'audio' Availability: On request Capabilities: audio/x-adpcm layout: swf channels: { (int)1, (int)2 } rate: { (int)5512, (int)11025, (int)22050, (int)44100 } audio/mpeg mpegversion: 1 layer: 3 channels: { (int)1, (int)2 } rate: { (int)5512, (int)8000, (int)11025, (int)22050, (int)44100 } parsed: true audio/mpeg mpegversion: { (int)4, (int)2 } stream-format: raw audio/x-nellymoser channels: { (int)1, (int)2 } rate: { (int)5512, (int)8000, (int)11025, (int)16000, (int)22050, (in t)44100 } audio/x-raw format: { (string)U8, (string)S16LE } layout: interleaved channels: { (int)1, (int)2 } rate: { (int)5512, (int)11025, (int)22050, (int)44100 } audio/x-alaw channels: { (int)1, (int)2 } rate: 8000 audio/x-mulaw channels: { (int)1, (int)2 } rate: 8000 audio/x-speex channels: 1 rate: 16000 Type: GstFlvMuxPad Pad Properties: emit-signals : Send signals to signal data consumption flags: readable, writable Boolean. Default: false SRC template: 'src' Availability: Always Capabilities: video/x-flv Type: GstAggregatorPad Pad Properties: emit-signals : Send signals to signal data consumption flags: readable, writable Boolean. Default: false SINK template: 'video' Availability: On request Capabilities: video/x-flash-video video/x-flash-screen video/x-vp6-flash video/x-vp6-alpha video/x-h264 stream-format: avc Type: GstFlvMuxPad Pad Properties: emit-signals : Send signals to signal data consumption flags: readable, writable Boolean. Default: false Element has no clocking capabilities. Element has no URI handling capabilities. Pads: SRC: 'src' Pad Template: 'src' Element Properties: emit-signals : Send signals flags: readable, writable Boolean. Default: false encoder : The value of encoder in the meta packet. flags: readable, writable String. Default: "GStreamer 1.20.7.1 FLV muxer" latency : Additional latency in live mode to allow upstream to take longer to produce buffers for the current position (in nanoseconds) flags: readable, writable Unsigned Integer64. Range: 0 - 18446744073709551615 Default: 0 meta-binary : Binary metadata (GBytes) flags: readable, writable Boxed pointer of type "GBytes" meta-string : Custom string to include as metadata flags: readable, writable String. Default: null metadatacreator : The value of metadatacreator in the meta packet. flags: readable, writable String. Default: "GStreamer 1.20.7.1 FLV muxer" min-upstream-latency: When sources with a higher latency are expected to be plugged in dynamically after the aggregator has started playing, this allows overriding the minimu m latency reported by the initial source(s). This is only taken into account when larger than the actually reported minimum latency. (nanoseconds) flags: readable, writable Unsigned Integer64. Range: 0 - 18446744073709551615 Default: 0 name : The name of the object flags: readable, writable, 0x2000 String. Default: "flvmux0" parent : The parent of the object flags: readable, writable, 0x2000 Object of type "GstObject" skip-backwards-streams: If set to true, streams that go backwards related to the other stream will have buffers dropped until they reach the correct timestamp flags: readable, writable Boolean. Default: false start-time : Start time to use if start-time-selection=set flags: readable, writable Unsigned Integer64. Range: 0 - 18446744073709551615 Default: 184 46744073709551615 start-time-selection: Decides which start time is output flags: readable, writable Enum "GstAggregatorStartTimeSelection" Default: 0, "zero" (0): zero - GST_AGGREGATOR_START_TIME_SELECTION_Z ERO (1): first - GST_AGGREGATOR_START_TIME_SELECTION_F IRST (2): set - GST_AGGREGATOR_START_TIME_SELECTION_S ET streamable : If set to true, the output should be as if it is to be streamed and hence no indexes written or duration written. flags: readable, writable Boolean. Default: false Element Signals: "samples-selected" : void user_function (GstElement* object, GstSegment* arg0, guint64 arg1, guint64 arg2, guint64 arg3, GstStructure* arg4, gpointer user_data);
Important Notes
- The flvmux element supports embedding metadata fields with meta-* keys into the output FLV file or stream.
- This metadata is later recognized by the demuxer for automatic extraction.
FlvDemux element
The expected output of running
gst-inspect-1.0 flvdemux
is the following:
Factory Details: Rank primary (256) Long-name FLV Demuxer Klass Codec/Demuxer Description Demux FLV feeds into digital streams Author Julien Moutte <julien@moutte.net> Plugin Details: Name flv Description FLV muxing and demuxing plugin Filename /home/jsantamaria/work/rnd/1.20/001/gstreamer/builddir/subprojects/gst-plugins-good/gst/flv/libgstflv.so Version 1.20.7.1 License LGPL Source module gst-plugins-good Binary package GStreamer Good Plug-ins git Origin URL Unknown package origin GObject +----GInitiallyUnowned +----GstObject +----GstElement +----GstFlvDemux Pad Templates: SRC template: 'audio' Availability: Sometimes Capabilities: audio/x-adpcm layout: swf channels: { (int)1, (int)2 } rate: { (int)5512, (int)11025, (int)22050, (int)44100 } audio/mpeg mpegversion: 1 layer: 3 channels: { (int)1, (int)2 } rate: { (int)5512, (int)8000, (int)11025, (int)22050, (int)44100 } parsed: true audio/mpeg mpegversion: 4 stream-format: raw framed: true audio/x-nellymoser channels: { (int)1, (int)2 } rate: { (int)5512, (int)8000, (int)11025, (int)16000, (int)22050, (in t)44100 } audio/x-raw format: { (string)U8, (string)S16LE } layout: interleaved channels: { (int)1, (int)2 } rate: { (int)5512, (int)11025, (int)22050, (int)44100 } audio/x-alaw channels: { (int)1, (int)2 } rate: 8000 audio/x-mulaw channels: { (int)1, (int)2 } rate: 8000 audio/x-speex channels: 1 rate: 16000 SINK template: 'sink' Availability: Always Capabilities: video/x-flv SRC template: 'video' Availability: Sometimes Capabilities: video/x-flash-video flvversion: 1 video/x-flash-screen video/x-vp6-flash video/x-vp6-alpha video/x-h264 stream-format: avc Element has no clocking capabilities. Element has no URI handling capabilities. Pads: SINK: 'sink' Pad Template: 'sink' Element Properties: attach-flvmeta : Attach custom onMetaData (meta-*) as GstFlvMeta to first audio a nd video buffers flags: readable, writable Boolean. Default: false flv-meta-signal : Emit a signal carrying custom onMetaData (meta-*) payload as GBy tes flags: readable, writable Boolean. Default: false name : The name of the object flags: readable, writable, 0x2000 String. Default: "flvdemux0" parent : The parent of the object flags: readable, writable, 0x2000 Object of type "GstObject" Element Signals: "pad-added" : void user_function (GstElement* object, GstPad* arg0, gpointer user_data); "pad-removed" : void user_function (GstElement* object, GstPad* arg0, gpointer user_data); "no-more-pads" : void user_function (GstElement* object, gpointer user_data); "flv-meta" : void user_function (GstElement* object, GBytes* arg0, gpointer user_data);
Important Properties
Injecting metadata
- meta-string:
- Use this property on flvmux
to insert metadata as a UTF-8 string into the outgoing stream.
- meta-binary:
- Use this property onflvmux
to insert metadata as binary data (GBytes
).
- GstFlvMeta (injection):
- You can attach aGstFlvMeta
to an upstream buffer, andflvmux
will serialize and embed that metadata into the FLV stream.
Extracting metadata
- attach-flvmeta:
- If set to TRUE,flvdemux
attaches the extracted metadata from theonMetaData
message asGstFlvMeta
on outgoing buffers. - This makes the metadata available downstream in the pipeline.
- flv-meta signal:
- Ifflv-meta-signal
is enabled,flvdemux
emits theflv-meta
signal with the metadata payload asGBytes
. - This allows applications to listen for metadata events without inspecting buffers directly.
Summary
- Muxing side (flvmux): add meta-* fields to inject metadata into FLV streams.
- Demuxing side (flvdemux): enable the property attach-flvmeta to have the metadata automatically attached to buffers as GstMeta.