With gstreamer tee element, pre-roll is not completing - gstreamer

In the below example pipeline,
gst-launch-1.0 -v videotestsrc num-buffers=100 ! "video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12" ! videoscale ! "video/x-raw, width=1280, height=720, format=NV12" ! tee name=t ! queue ! fakesink t. ! queue ! x264enc rc-lookahead=5 ! fakesink
The pipeline is not completing the pre-roll, async-done message is not reaching the gst-launch-1.0
This works only with "async=false". But why is this required, why is it not working without "async=false" ?

Related

Multiple RTMP inputs - picture in picture - stream offline handling

I'm using gstreamer to make a picture-in-picture composition of two rtmp inputs into an rtmp output.
I've managed to create a pipeline that works very well when both streams are offline
However, when one of the rtmp streams is not live when starting the pipeline - the pipeline does not start.
Does anyone know how to overcome this issue, and make sure the pipeline is not blocked if one rtmp source is offline?
You may have to insert identity into compositor input sub-pipelines.
Simulating 2 sources on localhost with:
gst-launch-1.0 videotestsrc ! x264enc insert-vui=1 ! h264parse config-interval=1 ! mpegtsmux ! rtpmp2tpay ! udpsink port=5004
(and second source the same to port 5005), the following runs fine for 0, 1 or 2 sources active at launch time:
gst-launch-1.0 -v \
udpsrc port=5004 ! application/x-rtp,media=video,encoding-name=MP2T,clock-rate=90000,payload=33 ! rtpjitterbuffer latency=300 ! rtpmp2tdepay ! tsdemux ! h264parse ! avdec_h264 ! videoconvert ! identity ! queue ! comp.sink_0 \
udpsrc port=5005 ! application/x-rtp,media=video,encoding-name=MP2T,clock-rate=90000,payload=33 ! rtpjitterbuffer latency=300 ! rtpmp2tdepay ! tsdemux ! h264parse ! avdec_h264 ! videoconvert ! identity ! queue ! comp.sink_1 \
compositor name=comp sink_0::xpos=0 sink_0::ypos=0 sink_0::width=320 sink_0::height=240 sink_1::xpos=0 sink_1::ypos=240 sink_1::width=320 sink_1::height=240 ! video/x-raw,width=320,height=480 ! videoconvert ! xvimagesink
For rtmp, with mpeg audio from first source, it would be something like:
gst-launch-1.0 -v \
rtmpsrc <your source1 and options> ! flvdemux name=demux0 ! queue ! h264parse ! avdec_h264 ! videoconvert ! identity ! queue ! comp.sink_0 \
rtmpsrc <your source2 and options> ! flvdemux name=demux1 ! queue ! h264parse ! avdec_h264 ! videoconvert ! identity ! queue ! comp.sink_1 \
compositor name=comp sink_0::xpos=0 sink_0::ypos=0 sink_0::width=320 sink_0::height=240 sink_1::xpos=0 sink_1::ypos=240 sink_1::width=320 sink_1::height=240 ! video/x-raw,width=320,height=480 ! videoconvert ! autovideosink \
demux0. ! queue ! audio/mpeg ! decodebin ! audioconvert ! audioresample ! autoaudiosink

Mix webcam video, audio with gstreamer

How to mix h264 format with audio on webcam with gstreamer?
gst-launch-1.0 -v v4l2src device=/dev/video2 ! video/x-h264,framerate=30/1,width=1920,height=1080 \
! queue ! mux. \
alsasrc device=hw:1 ! queue ! audioconvert ! fdkaacenc \
! mux. matroskamux name=mux ! filesink location=video.mkv
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstAudioSrcClock
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
../libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.001309727
Setting pipeline to NULL ...
Freeing pipeline ...
Preview works
gst-launch-1.0 -v \
v4l2src device=/dev/video2 ! video/x-h264,framerate=30/1,width=1920,height=1080 ! decodebin ! autovideosink
Audio works
gst-launch-1.0 -v alsasrc device=hw:1 ! queue ! audioconvert ! fdkaacenc ! fdkaacdec ! autoaudiosink
h264parse needed before mux
gst-launch-1.0 -v \
v4l2src device=/dev/video2 ! queue ! video/x-h264,framerate=30/1,width=1920,height=1080 \
! h264parse ! mux. \
alsasrc device=hw:1 ! queue ! audioconvert ! fdkaacenc ! mux. \
matroskamux name=mux ! filesink location=video.mp4

Why does gstreamer tee fail with udpsrc?

This gstreamer pipeline, with 1 sink, works:
gst-launch-1.0 udpsrc port=5600 do-timestamp=true ! application/x-rtp,media=video,clock-rate=90000,encoding-name=H264 ! queue ! rtph264depay ! h264parse ! avdec_h264 ! autovideosink
This pipeline, with 2 sinks, also works:
gst-launch-1.0 videotestsrc ! tee name=t ! queue ! autovideosink t. ! queue ! autovideosink
But this pipeline, with 2 sinks, stalls:
gst-launch-1.0 udpsrc port=5600 do-timestamp=true ! application/x-rtp,media=video,clock-rate=90000,encoding-name=H264 ! queue ! rtph264depay ! h264parse ! tee name=t queue ! avdec_h264 ! autovideosink t. ! queue ! avdec_h264 ! autovideosink
Why?
Version info:
$ gst-launch-1.0 --version
gst-launch-1.0 version 1.16.2
GStreamer 1.16.2
https://launchpad.net/distros/ubuntu/+source/gstreamer1.0
Thanks!
! tee name=t queue !
You are missing a ! between the tee and the queue.

Using SRT protocol in Gstreamer

Using the following 2 commands I can stream a videotestsrc source over SRT.
gst-launch-1.0 -v videotestsrc ! queue ! x264enc ! queue ! mpegtsmux alignment=7 ! identity silent=false ! queue leaky=downstream ! srtsink uri="srt://:8888" sync=false async=false
gst-launch-1.0 -v srtsrc uri="srt://127.0.0.1:8888" ! identity silent=false ! fakesink async=false
And play it in this way:
gst-play-1.0 srt://127.0.0.1:8888
Now I want to stream a rtsp source, and I get it in the following way:
gst-launch-1.0 rtspsrc location=rtsp://localhost:8554/main latency=100 ! queue ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! videoscale ! video/x-raw,width=640,height=480 ! srtsink uri="srt://:8888" sync=false async=false
gst-launch-1.0 -v srtsrc uri="srt://127.0.0.1:8888" ! identity silent=false ! fakesink async=false
However, when I when to playback I have this error:
gst-play-1.0 srt://127.0.0.1:8888
Press 'k' to see a list of keyboard shortcuts.
Now playing srt://127.0.0.1:8888
Pipeline is live.
ERROR Could not determine type of stream. for srt://127.0.0.1:8888
ERROR debug information: ../subprojects/gstreamer/plugins/elements/gsttypefindelement.c(999): gst_type_find_element_chain_do_typefinding (): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0/GstDecodeBin:decodebin0/GstTypeFindElement:typefind
Reached end of play list.
How can I solve it?

How to use gstreamer for transcoding and resizing from mp4(h264/aac) to mp4(h264/mp3)?

I want to transcode and resize mp4.(mp4-h264_1920x1080/aac => mp4-h264_640x480/mp3) using gstreamer. I wrote down this command.
$ gst-launch-0.10 filesrc location=./gain_1.mp4 ! qtdemux name=demux demux.video_00 ! queue ! ffdec_h264 ! videoscale ! 'video/x-raw-yuv,width=640,height=480' ! x264enc ! queue ! qtmux name=mux mux.video_0 demux.audio_00 ! queue ! ffdec_aac ! lame bitrate=128 ! queue ! mux.audio_0 mux. ! filesink location=0000.mp4 –v -e
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Redistribute latency...
^CCaught interrupt -- handling interrupt.
Interrupt: Stopping pipeline ...
(gst-launch-0.10:17958): GLib-CRITICAL **: Source ID 1 was not found when attempting to remove it
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
which didn't work.
Transcoding video-only works :
gst-launch-0.10 filesrc location=./gain_1.mp4 ! qtdemux name=demux demux.video_00 ! queue ! ffdec_h264 ! videoscale ! 'video/x-raw-yuv, width=640, height=480' ! x264enc ! queue ! mux. mp4mux name=mux ! filesink location=0000.mp4 –v -e
And transcoding audio-only too:
gst-launch-0.10 filesrc location=./gain_1.mp4 ! qtdemux name=demux demux.audio_00 ! ffdec_aac ! lame bitrate=128 ! queue ! mux. mp4mux name=mux ! filesink location=0000.mp4 –v -e
How can I transcode audio and video with the same command?
#Lionel.J I would like to suggest two improvements:
if possible, use gstreamer-1
your solution reads the source file twice. That's not necessary. Furthermore, the audio and video streams are not synchronized when you do this. You can read both audio and video streams out of qtdemux.
This is a pipeline which does the job with gstreamer-1 and reads the source only once:
gst-launch-1.0 -e filesrc location=/path/to/big_buck_bunny_720p_h264.mov ! \
decodebin name=decode ! \
videoscale ! 'video/x-raw,width=640,height=480' ! \
x264enc ! queue ! mp4mux name=mp4mux ! filesink location=0000.mp4 \
decode. ! audioconvert ! lamemp3enc bitrate=128 ! queue ! mp4mux.
Oh~
I solved this problem.
Next command did good work.
gst-launch-0.10 ffmux_mp4 name=mux ! \
filesink location=0000.mp4 \
filesrc location=./gain_1.mp4 ! qtdemux name=vdemux vdemux.video_00 ! queue ! ffdec_h264 ! videoscale ! 'video/x-raw-yuv, width=640, height=480' ! x264enc ! queue ! mux. \
filesrc location=./gain_1.mp4 ! qtdemux name=ademux ademux.audio_00 ! ffdec_aac ! lame bitrate=128 ! queue ! mux.`