NVIDIA Advanced GStreamer Pipelines with Gstd: Difference between revisions

no edit summary
No edit summary
Line 281: Line 281:


Sometimes it might be required to include metadata in the stream to add any additional information. Our solution [[GStreamer_In-Band_Metadata_for_MPEG_Transport_Stream|GStreamer In-Band Metadata for MPEG Transport Stream]] makes it easier for your convenience.  
Sometimes it might be required to include metadata in the stream to add any additional information. Our solution [[GStreamer_In-Band_Metadata_for_MPEG_Transport_Stream|GStreamer In-Band Metadata for MPEG Transport Stream]] makes it easier for your convenience.  
=== Sending Metadata through TCP ===
In this example we will show how to send/receive the metadata through a TCP socket. First, we create the TCP metadata source with the following pipeline:
<source lang=bash>
META_SOURCE_IP="10.251.101.238"
META_SOURCE_PORT="3001"
gst-client pipeline_create tcp_meta metasrc is-live=true name=meta ! tcpserversink host=${META_SOURCE_IP} port=${META_SOURCE_PORT}
</source>
The metasrc element may send any kind of binary metadata, but it requires an application to do that. Instead, we will show how to send specifically string data using gstd. To do this just set the ''metadata'' property with the text you would like to send:
<source lang=bash>
gst-client element_set tcp_meta meta metadata Hello_TCP
</source>
This will send the metadata just once, but if we want it to send it periodically we just need to set the ''period'' property of the metasrc element. For example, if we want to send it every second it would be like this:
<source lang=bash>
gst-client element_set tcp_meta meta period 1
</source>
Then we play the pipeline:
<source lang=bash>
gst-client pipeline_play tcp_meta
</source>


=== Modifying the Processing Pipe to Support Metadata ===
=== Modifying the Processing Pipe to Support Metadata ===


We can add metadata support by slightly modifying the '''proc_pipe'' of our last example like this:
We can add metadata support by slightly modifying the '''proc_pipe'' of our last example.


<source lang=bash>
<source lang=bash>
MULTICAST_IP="224.1.1.1"
MULTICAST_IP="224.1.1.1"
PORT="12345"
PORT="12345"
META_SOURCE_IP="10.251.101.238"
META_SOURCE_PORT="3001"
WIDTH=640
WIDTH=640
HEIGHT=480
HEIGHT=480
Line 297: Line 327:
FRAMERATE=30
FRAMERATE=30
gst-client pipeline_create proc_pipe interpipesrc name=interpipe listen-to=test_src is-live=true format=time ! videorate name=framerate_filter max-rate=${FRAMERATE} drop-only=true ! nvvidconv name=cropper top=${ROI_TOP} bottom=${ROI_BOTTOM} left=${ROI_LEFT} right=${ROI_RIGHT} ! capsfilter name=scale_filter caps="video/x-raw(memory:NVMM),width=${WIDTH},height=${HEIGHT}" ! queue max-size-buffers=3 leaky=downstream ! nvv4l2h265enc name=encoder bitrate=2000000 iframeinterval=300 vbv-size=33333 insert-sps-pps=true control-rate=constant_bitrate profile=Main num-B-Frames=0 ratecontrol-enable=true preset-level=UltraFastPreset EnableTwopassCBR=false maxperf-enable=true ! h265parse ! mpegtsmux alignment=7 name=mux ! queue ! udpsink name=output_udp host="${MULTICAST_IP}" port=${PORT} auto-multicast=true sync=false \
gst-client pipeline_create proc_pipe interpipesrc name=interpipe listen-to=test_src is-live=true format=time ! videorate name=framerate_filter max-rate=${FRAMERATE} drop-only=true ! nvvidconv name=cropper top=${ROI_TOP} bottom=${ROI_BOTTOM} left=${ROI_LEFT} right=${ROI_RIGHT} ! capsfilter name=scale_filter caps="video/x-raw(memory:NVMM),width=${WIDTH},height=${HEIGHT}" ! queue max-size-buffers=3 leaky=downstream ! nvv4l2h265enc name=encoder bitrate=2000000 iframeinterval=300 vbv-size=33333 insert-sps-pps=true control-rate=constant_bitrate profile=Main num-B-Frames=0 ratecontrol-enable=true preset-level=UltraFastPreset EnableTwopassCBR=false maxperf-enable=true ! h265parse ! mpegtsmux alignment=7 name=mux ! queue ! udpsink name=output_udp host="${MULTICAST_IP}" port=${PORT} auto-multicast=true sync=false \
metasrc name=meta ! meta/x-klv ! queue ! mux.
tcpclientsrc host=${META_SOURCE_IP} port=${META_SOURCE_PORT} ! queue ! mux.meta_54
</source>
</source>


Here we are adding another stream to the MPEG-TS multiplexer so that receiver applications can process the metadata in a separate way too.
Here we are adding the incoming TCP stream to the MPEG-TS multiplexer so that receiver applications can process the metadata in a separate way too. The '''meta_54''' is an identifier for the stream used to demux the content of the receiving side in case there are multiple metadata streams muxed.


=== Sending Metadata ===
Then we play the processing pipeline:
 
The metasrc element may send any kind of binary metadata, but it requires an application to do that. Instead, we will show how to send specifically string data using gstd. To do this just set the ''metadata'' property with the text you would like to send:


<source lang=bash>
<source lang=bash>
gst-client element_set proc_pipe meta metadata Hello_WORLD
gst-client pipeline_play proc_pipe
</source>
 
This will send the metadata just once, but if we want it to send it periodically we just need to set the ''period'' property of the metasrc element. For example, if we want to send it every second it would be like this:
 
<source lang=bash>
gst-client element_set proc_pipe meta period 1
</source>
</source>


Line 323: Line 345:
ADDRESS=224.1.1.1
ADDRESS=224.1.1.1
PORT=12345
PORT=12345
gst-launch-1.0 udpsrc port=${PORT} address=${ADDRESS} ! tsdemux name=demux ! queue ! h265parse ! avdec_h265 ! queue ! videoconvert ! autovideosink sync=false demux. ! queue ! 'meta/x-klv' ! metasink -v
gst-launch-1.0 udpsrc port=${PORT} address=${ADDRESS} ! tsdemux name=demux ! queue ! h265parse ! avdec_h265 ! queue ! videoconvert ! autovideosink sync=false demux.private_0_0036 ! queue ! 'meta/x-klv' ! metasink -v
</source>
</source>
Note that in the '''private_0_0036''' identifier the '''36''' corresponds to the hexadecimal representation of the '''meta_54''' identifier we used in the muxer.


Here the ''metasink'' element will allow us to see without an extra application the sent metadata, since it will dump the contents to the standard output in a way similar to this:
Here the ''metasink'' element will allow us to see without an extra application the sent metadata, since it will dump the contents to the standard output in a way similar to this:


<source lang=bash>
<source lang=bash>
00000000 (0x7f9002ce10): 48 65 6c 6c 6f 5f 57 4f 52 4c 44 00             Hello_WORLD.  
00000000 (0x7fd0f002d590): 48 65 6c 6c 6f 5f 54 43 50 00                   Hello_TCP.    
00000000 (0x7f9002f070): 48 65 6c 6c 6f 5f 57 4f 52 4c 44 00             Hello_WORLD.  
00000000 (0x7fd0f002d550): 48 65 6c 6c 6f 5f 54 43 50 00                   Hello_TCP.    
00000000 (0x7f9002cdd0): 48 65 6c 6c 6f 5f 57 4f 52 4c 44 00             Hello_WORLD.  
00000000 (0x7fd0f002d5b0): 48 65 6c 6c 6f 5f 54 43 50 00                   Hello_TCP.    
00000000 (0x7f9002e6f0): 48 65 6c 6c 6f 5f 57 4f 52 4c 44 00             Hello_WORLD.  
00000000 (0x7fd0f002d650): 48 65 6c 6c 6f 5f 54 43 50 00                   Hello_TCP.    
00000000 (0x7f9002cd30): 48 65 6c 6c 6f 5f 57 4f 52 4c 44 00             Hello_WORLD.  
00000000 (0x7fd0f002d670): 48 65 6c 6c 6f 5f 54 43 50 00                   Hello_TCP.    
00000000 (0x7f9002e280): 48 65 6c 6c 6f 5f 57 4f 52 4c 44 00             Hello_WORLD.  
00000000 (0x7fd0f002d690): 48 65 6c 6c 6f 5f 54 43 50 00                   Hello_TCP.    
00000000 (0x7f9002f010): 48 65 6c 6c 6f 5f 57 4f 52 4c 44 00             Hello_WORLD.  
00000000 (0x7fd0f002d6b0): 48 65 6c 6c 6f 5f 54 43 50 00                   Hello_TCP.  
</source>
</source>


334

edits