I am receiving a video stream (mpegts
over rtp
over udp
). for the moment I need to start the "receiver" before the "streamer" gstreamer command. Is there a way to receive the stream while active?
So I don't need to start the receiver before the streamer.
I may not be able to choose when the stream starts or stop so it is important that I can receive it even when already playing.
gst-launch-1.0 -v udpsrc port=XXXX \
caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)MP2T, payload=(int) 33" \
! queue leaky=upstream min-threshold-time=10000000 ! rtpmp2tdepay ! tsparse ! tsdemux name=DEM \
DEM. ! video/x-h264 ! queue ! decodebin ! queue autovideosink \
DEM. ! queue ! aacparse ! decodebin ! audioconvert ! queue ! autoaudiosink
Thanks a lot
Edit
So thanks to @SeB I could get it to work. The important point were:
- Using
h264parse config-interval=1
to send the config every second. - Using
rtpjitterbuffer latency=500
to reorder the rtp stream packets before thertpmp2tdemux
- Do not use
tsparse
after thetsmux
in the streaming command. If I do so, a lot of frames are missing or broken and I get something really unstable as result.
Nevertheless,
- I didn't need
videoconvert
element - I am still using the
autovideosink
- I replaced the
decodebin
by the real pipeline
Result
The resulting pipeline look like something like that:
gst-launch-1.0 -v udpsrc port=5000 \
caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)MP2T, payload=(int) 33" \
! queue leaky=upstream min-threshold-time=10000000 \
! rtpjitterbuffer latency=500 ! rtpmp2tdepay
! tsparse ! tsdemux name=DEM \
DEM. ! video/x-h264 ! queue ! h264parse ! avdec_h264 ! queue autovideosink \
DEM. ! queue ! aacparse ! avdec_aac \
! audioresample ! audioconvert ! queue ! autoaudiosink
CodePudding user response:
The simplest way would be to have the sender to periodically send config so that your receiver can setup. There are various way to do that:
# Using config-interval property of h264parse:
gst-launch-1.0 videotestsrc ! x264enc ! h264parse config-interval=1 ! mpegtsmux ! tsparse ! rtpmp2tpay ! udpsink port=5000
# Using insert-vui in x264enc:
gst-launch-1.0 videotestsrc ! x264enc insert-vui=1 ! h264parse ! mpegtsmux ! tsparse ! rtpmp2tpay ! udpsink port=5000
# For NVIDIA encoder:
gst-launch-1.0 videotestsrc ! nvvidconv ! nvv4l2h264enc insert-sps-pps=1 ! h264parse ! mpegtsmux ! tsparse ! rtpmp2tpay ! udpsink port=5000
Then you can get the video at any time (it may take a few seconds to setup and display, though) with something like (here for Linux running X):
gst-launch-1.0 -v udpsrc port=5000 ! application/x-rtp,media=video,encoding-name=MP2T,clock-rate=90000,payload=33 ! rtpjitterbuffer latency=300 ! rtpmp2tdepay ! tsdemux ! h264parse ! avdec_h264 ! videoconvert ! xvimagesink