I'm new to gstreamer, and I want to stream webcam video through network with mpeg2-ts. I am able to stream video using following pipeline, but I don't know how to stream it with mpeg2-ts using mpegmux
. Any help would be great! Thanks.
My working pipline (without mpegmux
) :
// Sender
gst-launch-1.0 -ve v4l2src \
! video/x-raw, framerate=30/1 \
! videoconvert \
! x264enc noise-reduction=10000 speed-preset=fast tune=zerolatency byte-stream=true threads=4 key-int-max=15 intra-refresh=true \
! rtph264pay pt=96 \
! udpsink host=localhost port=5000
// Receiver
gst-launch-1.0 -ve udpsrc port=5000 \
! application/x-rtp, media=video, clock-rate=90000, encoding-name=H264, payload=96 \
! rtph264depay \
! h264parse \
! avdec_h264 \
! videoconvert \
! ximagesink sync=false
I've tried some methods like below, but still can't get it to work. Sender gives error "Could not link mux with rtph264pay" and receiver gives "Could not link mux with udpsrc".
// Sender
gst-launch-1.0 -ve v4l2src \
! video/x-raw, framerate=30/1 \
! videoconvert \
! x264enc noise-reduction=10000 speed-preset=fast tune=zerolatency byte-stream=true threads=4 key-int-max=15 intra-refresh=true \
! rtph264pay pt=96 \
! mpegtsmux name=mux mux. \
! udpsink host=localhost port=5000
// Reveiver
gst-launch-1.0 -ve udpsrc port=5000 \
! application/x-rtp, media=video, clock-rate=90000, encoding-name=H264, payload=96 \
! tsdemux name=demux demux.video_00 \
! rtph264depay \
! h264parse \
! avdec_h264 \
! videoconvert \
! ximagesink sync=false
Note that, I use tsdemux
instead of mpegtsdemux
in the receiver because it will output ' no element "mpegtsdemux" '. However, I if type $ gst-inspect-1.0 mpegtsdemux
it prints:
Plugin Details:
Name mpegtsdemux
Description MPEG TS demuxer
Filename /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstmpegtsdemux.so
Version 1.2.4
License unknown
Source module gst-plugins-bad
Source release date 2014-04-18
Binary package GStreamer Bad Plugins (Ubuntu)
Origin URL https://launchpad.net/distros/ubuntu/+source/gst-plugins-bad1.0
tsdemux: MPEG transport stream demuxer
tsparse: MPEG transport stream parser
2 features:
+-- 2 elements
I have no idea why gst-launch-1.0 can't find mpegtsdemux
.
EDIT:
Thanks to @otopolsky, I've figured out a working pipeline(see below). And also, he/she is right about not having to use caps in receiver if tsparse
is placed before tsdemux
.
// Sender
gst-launch-1.0 -ve v4l2src \
! video/x-raw, framerate=30/1 \
! videoconvert \
! x264enc noise-reduction=10000 tune=zerolatency byte-stream=true threads=4 key-int-max=15 intra-refresh=true \
! mpegtsmux \
! udpsink host=localhost port=5000
// Receiver
gst-launch-1.0 -ve udpsrc port=5000 \
! tsparse \
! tsdemux \
! h264parse \
! avdec_h264 \
! videoconvert \
! ximagesink sync=false
Just a few more questions:
- Why I don't need to add
rtpmp2tdepay
in the receiver side? (If I add it anywhere in the pipeline, the "Could not link rtpmp2tdepay with xx" will be generated.) - The quality of the streaming video would be worse than the one without using
mpegtsmux
. Why is that? Is it because it uses mpeg2-ts? Is there any tips for improving the streaming quality?
gst-inspect-1.0 element
.. 2, to the quality.. I think the processing is different somehow - very low quality is achieved with zerolatency, so this is maybe causing this.. what about removing zerolatency and add some nice speed preset? – Lactoproteinspeed-preset
to any value lower thanultrafast
(which has the same quality as zerolatency) will make streaming very laggy on my device, so I would use zerolatency for now. – Martinertpmp2tpay
in sender, the video quality is much better now. It seems to be redundant. – Martine