Stream audio and video with gstreamer - gstreamer

I'm trying to stream an arbitrary file with gstreamer, I have the following command line but it does not work (I will use python when I get this to work)
gst-launch-1.0 uridecodebin uri=file:///tmp/File.mkv name=decoder name=decbin \
! queue\
! videoconvert ! x264enc \
! mp4mux name=muxer ! udpsink host=127.0.0.1 port=1234 decbin. \
! queue \
! audioconvert ! lamemp3enc ! muxer.
and playing with
gst-launch-1.0 udpsrc port=1234 ! 'application/x-rtp,payload=96'\
! rtph264depay ! decodebin ! xvimagesink sync=false
I know I have to add rtph264pay and rtpmpapay but I don't know where.

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

Save RTSP stream to file

I cant save audio from stream I get only video in file. I suspect that I do not need two filesink in pipeline or there is some problem two different mux.
I tried to use autoadiosink and autovideosink and they works successfully.
autoadiosink and autovideosink pipeline:
gst-launch-1.0 rtspsrc location=rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov latency=0 droponlatency=1 name=rtp_source ! queue ! rtph264depay ! decodebin ! videoconvert ! autovideosink rtp_source. ! queue ! decodebin ! autoaudiosink
Save to file filesink pipeline:
gst-launch-1.0 rtspsrc location=rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov latency=0 droponlatency=1 name=rtp_source ! queue ! rtph264depay ! decodebin ! vp8enc ! webmmux ! filesink location=BigBuckBunny_115k.webm rtp_source. ! "application/x-rtp, media=(string)audio" ! queue ! decodebin ! vorbisenc ! oggmux ! filesink location=BigBuckBunny_115k.webm
I want to get also audio in resulting file.
You just reuse the existing mux - so that the vorbis is put into the webmmux too:
gst-launch-1.0 rtspsrc location=rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov \
latency=0 droponlatency=1 name=rtp_source ! queue ! rtph264depay ! decodebin ! \
vp8enc ! webmmux name=mux ! filesink location=BigBuckBunny_115k.webm rtp_source. ! \
application/x-rtp, media=(string)audio" ! queue ! decodebin ! vorbisenc ! mux.

Gstreamer pipeline for converting files with optional audio/video

I am using the following pipeline to convert an flv file to mp4.
gst-launch-1.0 -vvv -e filesrc location="c.flv" ! flvdemux name=demux \
demux.audio ! queue ! decodebin ! audioconvert ! faac bitrate=32000 ! mux. \
demux.video ! queue ! decodebin ! videoconvert ! video/x-raw,format=I420 ! x264enc speed-preset=superfast tune=zerolatency psy-tune=grain sync-lookahead=5 bitrate=480 key-int-max=50 ref=2 ! mux. \
mp4mux name=mux ! filesink location="c.mp4"
The problem is when (for example) audio is missing, the pipeline gets stuck. (Same thing happens if just hooking a fakesink to demux.audio).
I need a way for the filters to ignore missing tracks, or produce empty tracks.

play and record stream in the same time using gstreamer

Hi to all i try to play and record mp3 souphttpsrc in the same time but i don't have a good result someone can help please?
gst-launch-1.0 -e filesrc location=/dev/fd/0 ! h264parse ! tee name=myvid \! queue ! decodebin ! xvimagesink sync=false \ myvid. ! queue ! mux.video_0 \ alsasrc device="plughw:2,0" ! "audio/x-raw,rate=44100,channels=1,depth=24" ! audioconvert ! queue ! filesink location=/tmp/out.mp4
thank you
Hi your pipeline is slightly wrong.
There is no encoding happening with the audio so you're saving raw audio into the container.
There is no muxer and mux.video_0 therefore does not resolve to any pad on any element.
Here is a pipeline without these issues:
gst-launch-1.0 -e mp4mux name=mux ! filesink location=/tmp/out.mp4 filesrc location=/dev/fd/0 ! h264parse ! tee name=myvid ! queue ! decodebin ! xvimagesink sync=false myvid. ! queue ! mux.video_0 \ alsasrc device="plughw:2,0" ! "audio/x-raw,rate=44100,channels=1,depth=24" ! audioconvert ! queue ! lame ! mux.audio_0

GStreamer RTP full-duplex video in/out with single rtpbin

I'm trying to create gstreamer pipeline with rtpbin to stream webcam both way (videophone). However, I am not even able to make rtpbin work with simple snippet like below which just takes webcam source and streams out, then other udpsrc captures RTP packets and displays. All localhost. When splitted to two pipes and launched separately, it works. This, however, not. I feel it has something with threading, however I am stucked here as no queue worked for me so far.
Basically, what I need is displaying incomming videostream and stream out my webcam videostream out to remote party.
gst-launch -v \
gstrtpbin name=rtpbin \
udpsrc caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263" port=5000 ! rtpbin. \
rtpbin. ! rtph263depay ! ffdec_h263 ! ffmpegcolorspace ! xvimagesink \
v4l2src ! video/x-raw-yuv, framerate=30/1, width=320, height=240 ! videoscale ! videorate ! "video/x-raw-yuv,width=352,height=288,framerate=30/1" ! ffenc_h263 ! rtph263pay ! rtpbin. \
rtpbin. ! udpsink port=5000
Ok, I have to answer to myself, it was enough to add sync=false async=false to the udpsink:
gst-launch -v \
gstrtpbin name=rtpbin udpsrc caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263" port=5000 ! queue ! rtpbin. \
rtpbin. ! rtph263depay ! ffdec_h263 ! ffmpegcolorspace ! xvimagesink \
v4l2src ! video/x-raw-yuv, framerate=30/1, width=320, height=240 ! videoscale ! videorate ! "video/x-raw-yuv,width=352,height=288,framerate=30/1" ! ffenc_h263 ! rtph263pay ! rtpbin. \
rtpbin. ! udpsink port=5000 sync=false async=false