GstSEIMetadata - Examples - Using gst-launch

From RidgeRun Developer Connection
Jump to: navigation, search


Previous: Examples Index Next: Examples/Using Gstd




This page contains a series of command line examples that use gst-launch-1.0 to run GStreamer pipelines along with the GstSEI plugin, please check that the meta plugin is correctly installed on your system with gst-inspect.

Command:

gst-inspect-1.0 sei 

Expected output:

Plugin Details:
  Name                     sei
  Description              Gstreamer plugin to add meta-data as SEI NAL units
  Filename                 /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libsei.so
  Version                  0.1.0
  License                  Proprietary
  Source module            gst-sei
  Binary package           gst-sei
  Origin URL               Unknown package origin

  seiinject: SEI Inject Meta-data
  seiextract: SEI Extract Metadata
  seimetatester: Helper element to insert a test GstSeiMeta to buffers.

  3 features:
  +-- 3 elements

Inserting metadata

In this subsection, sample pipelines to insert and extract metadata are presented.

H264 example pipeline

The following pipeline encodes the output from the videotestsrc element with H264 encoding. Then, it injects metadata with the message "Hello World" by means of the seiinject element. Finally, the resulting buffers are sent into a file called Test.mp4

gst-launch-1.0 videotestsrc num-buffers=10 ! x264enc ! seiinject metadata="Hello World" ! qtmux ! filesink location=Test.mp4 -e

After that you can check the message was inserted by running

GST_DEBUG=*seiextract*:MEMDUMP gst-launch-1.0 filesrc location=Test.mp4 ! queue ! qtdemux ! video/x-h264 ! seiextract !  h264parse ! avdec_h264 !  queue ! fakesink

In the output you will see a MEMDUMP message with the following information:

The extracted data is: Hello World

To reproduce the video you can do:

gst-launch-1.0 filesrc location=Test.mp4 ! queue ! qtdemux ! video/x-h264 ! h264parse ! avdec_h264 ! queue ! videoconvert ! xvimagesink

H265 example pipeline

The following pipeline encodes the output from the videotestsrc element with H265 encoding. Then, it injects metadata with the message "Hello World" by means of the seiinject element. Finally, the resulting buffers are sent into a file called Test.mp4

gst-launch-1.0 videotestsrc num-buffers=10 ! x265enc ! h265parse ! seiinject metadata="Hello World" ! qtmux ! filesink location=Test.mp4 -e

After that you can check the message was inserted by running

GST_DEBUG=*seiextract*:MEMDUMP gst-launch-1.0 filesrc location=Test.mp4 ! queue ! qtdemux ! video/x-h265 ! seiextract !  h265parse ! avdec_h265 !  queue ! fakesink

In the output you will see a MEMDUMP message with the following information:

The extracted data is: Hello World

To reproduce the video you can do:

gst-launch-1.0 filesrc location=Test.mp4 ! queue ! qtdemux ! video/x-h265 ! h265parse ! avdec_h265 ! queue ! videoconvert ! xvimagesink

UDP

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 ! x264enc ! seimetatester ! seiinject ! mpegtsmux ! udpsink host=127.0.0.1 port=5000

On the client side:

gst-launch-1.0 udpsrc port=5000 ! tsdemux ! h264parse ! seiextract ! 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-stream, taglist=(taglist)"taglist\,\ video-codec\=\(string\)H.264\,\ minimum-bitrate\=\(uint\)1501200\,\ maximum-bitrate\=\(uint\)1637520\,\ bitrate\=\(uint\)1591360\;";) 0x7f7198005440
/GstPipeline:pipeline0/GstFakeSink:fakesink0: last-message = chain   ******* (fakesink0:sink) (6340 bytes, dts: 0:00:02.195672054, pts: none, duration: 0:00:00.033333333, offset: 395727, offset_end: -1, flags: 00002000 delta-unit , meta: none) 0x7f7198018900
/GstPipeline:pipeline0/GstFakeSink:fakesink0: last-message = chain   ******* (fakesink0:sink) (6 bytes, dts: 0:00:02.229005387, pts: 0:00:02.229005388, duration: 0:00:00.000000000, offset: 402067, offset_end: -1, flags: 00002000 delta-unit , meta: none) 0x7f71980182a0
/GstPipeline:pipeline0/GstFakeSink:fakesink0: last-message = chain   ******* (fakesink0:sink) (16 bytes, dts: 0:00:02.229005387, pts: none, duration: 0:00:00.000000000, offset: 402074, offset_end: -1, flags: 00006400 header delta-unit tag-memory , meta: GstSeiMeta) 0x7f71980186e0

Where you can check that metadata is being received as it says meta: GstSeiMeta.

In short, what the above pipeline does is to use seimetatester to create a GstMeta for each buffer, then inserts that GstMeta's content into the H264 stream by means of the seiinject element. After that, the H264 stream with the metadata inserted is sent over UDP to the client where the seiextract element is used to obtain the metadata and put it in a GstMeta element.

To see the video you can do:

gst-launch-1.0 udpsrc port=<port> ! tsdemux ! h264parse ! avdec_h264 ! videoconvert ! xvimagesink async=false sync=false

Another example would be:

On the client side (run this command first!):

GST_DEBUG=*seiextract*:MEMDUMP gst-launch-1.0 udpsrc port=5555 ! "application/x-rtp,media=video,clock-rate=90000,encoding-name=H264" ! rtph264depay ! h264parse ! seiextract ! fakesink

On the server side (run this command second!):

gst-launch-1.0 videotestsrc is-live=true num-buffers=5 ! x264enc ! seiinject metadata="HELLO WORLD" ! rtph264pay ! "application/x-rtp,media=video,clock-rate=90000,encoding-name=H264" ! udpsink host=127.0.0.1 port=5555

This will show a message (on the client side) that begins like this:

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
0:00:10.867518432  5043 0x55a1996d9000 DEBUG             seiextract gstseiextract.c:251:gst_sei_extract_set_caps:<seiextract0> set_caps
0:00:10.867571584  5043 0x55a1996d9000 DEBUG             seiextract gstseiextract.c:257:gst_sei_extract_set_caps: parsing caps: video/x-h264, stream-format=(string)avc, alignment=(string)au, codec_data=(buffer)0142c015ffe1001c6742c015d90141fb016a0c020b4a000003000200000300791e2c5c9001000468cb8cb2, level=(string)2.1, profile=(string)constrained-baseline, pixel-aspect-ratio=(fraction)1/1, width=(int)320, height=(int)240, framerate=(fraction)30/1, interlace-mode=(string)progressive, chroma-format=(string)4:2:0, bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8, parsed=(boolean)true
0:00:10.867937656  5043 0x55a1996d9000 LOG               seiextract gstseiextract.c:295:gst_sei_extract_prepare_output_buffer:<seiextract0> prepare_output_buffer
0:00:10.867961741  5043 0x55a1996d9000 LOG               seiextract gstseiextract.c:345:gst_sei_extract_prepare_output_buffer:<seiextract0> Not the expected payload type: 5

0:00:10.867973802  5043 0x55a1996d9000 LOG               seiextract gstseiextract.c:352:gst_sei_extract_prepare_output_buffer:<seiextract0> The extracted data is: HELLO WORLD
...

Where you can see the MEMDUMP message with the data HELLO WORLD.


Previous: Examples Index Next: Examples/Using Gstd