GStreamer pipelines
GstObuMetadata |
---|
GstObuMetadata Basics |
Getting Started |
User Guide |
Examples |
Contact Us |
This section shows basic usage examples of the GstObuMetadata plugin using GStreamer pipelines. Check the plugin information using the command gst-inspect
gst-inspect obu
The expected output is:
Plugin Details: Name obu Description Gstreamer plugin to add metadata as Open Bitstream Units (OBU) Filename /home/kcarvajal/work/devdirs/gstObuMetadata/install/lib/x86_64-linux-gnu/gstreamer-1.0/libobu.so Version 0.1.0 License Proprietary Source module gst-obu Binary package gst-obu Origin URL https://www.ridgerun.com/ obuextract: OBU extract metadata obuinject: OBU inject metadata 2 features: +-- 2 elements
Inserting metadata strings
The following sample pipeline shows metadata insertion and extraction using the GstObuMetadata plugin.
The pipeline encodes the output of the videotestsrc element with AV1 encoding. Then the video stream is injected with a string metadata with the message '"Hello World". Finally the video with the inserted metadata is saved in a file called test.mp4
gst-launch-1.0 videotestsrc is-live=true num-buffers=15 ! "video/x-raw, width=320, heigth=240" ! av1enc cpu-used=8 ! obuinject metadata="Hello World" ! qtmux ! filesink location=test.mp4
You can check the inserted metadata in the file in a MEMDUMP message by running:
GST_DEBUG=*obu*:MEMDUMP gst-launch-1.0 filesrc location=test.mp4 ! queue ! qtdemux ! obuextract ! fakesink
The expected MEMDUMP output should look like:
0:00:00.353844455 120696 0x55b41677db60 MEMDUMP obuextract gstobuextract.c:286:gst_obu_extract_prepare_output_buffer:<obuextract0> --------------------------------------------------------------------------- 0:00:00.353850506 120696 0x55b41677db60 MEMDUMP obuextract gstobuextract.c:286:gst_obu_extract_prepare_output_buffer:<obuextract0> The extracted data is 0:00:00.353860688 120696 0x55b41677db60 MEMDUMP obuextract gstobuextract.c:286:gst_obu_extract_prepare_output_buffer:<obuextract0> 00000000: 48 65 6c 6c 6f 20 57 6f 72 6c 64 Hello World 0:00:00.353864929 120696 0x55b41677db60 MEMDUMP obuextract gstobuextract.c:286:gst_obu_extract_prepare_output_buffer:<obuextract0> ---------------------------------------------------------------------------
The video can be reproduce using a av1 decoder and xvimagesink element:
GST_DEBUG=*obu*:MEMDUMP gst-launch-1.0 filesrc location=test.mp4 ! queue ! qtdemux ! obuextract ! av1dec ! videoconvert ! xvimagesink
UDP streaming
Another way to use the plugin would be to send metadata over UDP or other protocol. You can test the following example by opening two terminals in your computer (one for the server and one for the client) and running the commands.
On the server side:
gst-launch-1.0 videotestsrc is-live=true num-buffers=15 ! "video/x-raw, width=320, heigth=240" ! av1enc cpu-used=8 ! obuinject metadata="Hello World" ! qtmux ! udpsink host=127.0.0.1 port=5000 -v
On the client side:
GST_DEBUG=*obu*:MEMDUMP gst-launch-1.0 udpsrc port=5000 ! qtdemux ! obuextract ! fakesink silent=false -v
For every buffer you will see a message and one of the first buffers will have the MEMDUMP message with the metadata:
/GstPipeline:pipeline0/GstFakeSink:fakesink0: last-message = event ******* (fakesink0:sink) E (type: tag (20510), GstTagList-stream, taglist=(taglist)"taglist\,\ video-codec\=\(string\)AV1\;";) 0x7f31e0003720 /GstPipeline:pipeline0/GstFakeSink:fakesink0: last-message = event ******* (fakesink0:sink) E (type: tag (20510), GstTagList-global, taglist=(taglist)"taglist\,\ datetime\=\(datetime\)2024-02-12T23:10:14Z\,\ container-format\=\(string\)Quicktime\;";) 0x7f31e0005420 0:00:05.563025033 220219 0x56463b9d75e0 MEMDUMP obuextract gstobuextract.c:286:gst_obu_extract_prepare_output_buffer:<obuextract0> --------------------------------------------------------------------------- 0:00:05.563033177 220219 0x56463b9d75e0 MEMDUMP obuextract gstobuextract.c:286:gst_obu_extract_prepare_output_buffer:<obuextract0> The extracted data is 0:00:05.563042096 220219 0x56463b9d75e0 MEMDUMP obuextract gstobuextract.c:286:gst_obu_extract_prepare_output_buffer:<obuextract0> 00000000: 48 65 6c 6c 6f 20 57 6f 72 6c 64 Hello World 0:00:05.563045653 220219 0x56463b9d75e0 MEMDUMP obuextract gstobuextract.c:286:gst_obu_extract_prepare_output_buffer:<obuextract0> ---------------------------------------------------------------------------
GstObuMeta example
Another example is to add GstObuMeta structure to the buffer, the following example use the obumetatester element to create a GstMeta for each buffer.
On the server side:
gst-launch-1.0 videotestsrc is-live=true num-buffers=10 ! "video/x-raw, width=320, heigth=240" ! av1enc cpu-used=8 ! obumetatester ! obuinject ! qtmux ! udpsink host=127.0.0.1 port=5000 -v
On the client side:
GST_DEBUG=*obu*:MEMDUMP gst-launch-1.0 udpsrc port=5000 ! qtdemux ! obuextract ! fakesink silent=false -v
For every buffer you will see a message like this:
/GstPipeline:pipeline0/GstFakeSink:fakesink0: last-message = event ******* (fakesink0:sink) E (type: tag (20510), GstTagList-global, taglist=(taglist)"taglist\,\ datetime\=\(datetime\)2024-02-15T19:32:57Z\,\ container-format\=\(string\)Quicktime\;";) 0x7f530c005440 /GstPipeline:pipeline0/GstFakeSink:fakesink0: last-message = preroll ******* Redistribute latency... /GstPipeline:pipeline0/GstFakeSink:fakesink0: last-message = chain ******* (fakesink0:sink) (6061 bytes, dts: 0:00:00.000000000, pts: 0:00:00.000000000, duration: 0:00:00.033333333, offset: -1, offset_end: -1, flags: 00004040 discont tag-memory , meta: GstNetAddressMeta, GstNetAddressMeta, GstNetAddressMeta, GstNetAddressMeta, GstNetAddressMeta, GstNetAddressMeta, GstNetAddressMeta, GstNetAddressMeta, GstNetAddressMeta, GstNetAddressMeta, GstNetAddressMeta, GstObuMeta) 0x7f530c02b120 /GstPipeline:pipeline0/GstFakeSink:fakesink0: last-message = chain ******* (fakesink0:sink) (6330 bytes, dts: 0:00:00.033333333, pts: 0:00:00.033333333, duration: 0:00:00.033333333, offset: -1, offset_end: -1, flags: 00004000 tag-memory , meta: GstNetAddressMeta, GstNetAddressMeta, GstNetAddressMeta, GstNetAddressMeta, GstNetAddressMeta, GstNetAddressMeta, GstNetAddressMeta, GstNetAddressMeta, GstNetAddressMeta, GstNetAddressMeta, GstNetAddressMeta, GstObuMeta) 0x7f530c02b000
For each buffer we can check that metadata is being received as it is indicated in the meta property of the buffer as: GstObuMeta.
In short, what the above pipeline does is to use obumetatester to create a GstMeta for each buffer, then inserts that GstMeta's content into the AV1 stream using the obuinject element. The AV1 stream with the metadata inserted is sent over UDP to the client where the obuextract element is used to obtain the metadata and put it in a GstMeta element.