I’m trying a simple loop-back test with GNU Radio and GStreamer using the nvv4l2encoder and decoder for h264/mpegts stream. The video piped using a fifo file into GNU Radio, and then a UDP Sink block sends it back to localhost(127.0.0.1:12345) where the decoder pipeline tries to pick it up.
Capture GStreamer pipeline:
gst-launch-1.0 -e v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480,interlace-mode=interleaved ! timeoverlay halignment=left valignment=top text="Stream time:" shaded-background=true ! nvvidconv ! nvv4l2h264enc ! h264parse ! mpegtsmux ! filesink location=tx_video.ts sync=false
GNU Radio reads from tx_video.ts and sends it back to UDP@127.0.0.1:12345.
Playback GStreamer pipeline:
gst-launch-1.0 udpsrc uri=udp://127.0.0.1:12345 ! tsdemux ! queue ! h264parse ! nvv4l2decoder ! nvvidconv ! fpsdisplaysink text-overlay=true video-sink=xvimagesink -e sync=false
If I launch the playback pipeline first, it plays the video great. But if I start the capture pipeline first, the playback never plays the video stream. Is there a sync byte or header info it’s missing if it connects after the stream has started? I’m pretty new to GStreamer and the video streaming arena, any help is greatly appreciated!
Is your release version r32.3.1?
Yes, that is correct. I installed r32.3.1 using the SDK Manager.
When you start the receiver before the sender, you get the config in the first received bytes.
When you start the receiver after the sender, you’ve missed the config.
You may try to add option config-interval to h264 parse before mpegtsmux, so that it sends the config each second.
This seems ok:
gst-launch-1.0 -e videotestsrc ! video/x-raw,width=640,height=480,interlace-mode=interleaved ! timeoverlay halignment=left valignment=top text="Stream time:" shaded-background=true ! nvvidconv ! nvv4l2h264enc ! h264parse config-interval=1 ! mpegtsmux ! queue ! udpsink host=127.0.0.1 port=5000
gst-launch-1.0 -e udpsrc port=5000 ! tsdemux ! queue ! h264parse ! nvv4l2decoder ! nvvidconv ! fpsdisplaysink text-overlay=true video-sink=xvimagesink
Please try Honey_Patouceul’s suggestion.
You may also try to configure insert-sps-pps in nvv4l2h264enc:
insert-sps-pps : Insert H.264 SPS, PPS at every IDR frame
flags: readable, writable
Boolean. Default: false
Awesome, thanks all! Honey’s suggestion to add the config-interval option worked. I am going to try the insert-sps-pps option as well. Is there any kind of benefit of one over the other?
Both should be identical. You can set either property.