如何在Gstreamer中使用mpegtsmux进行网络摄像头流 [英] How to do webcam streaming with mpegtsmux in Gstreamer
问题描述
我是gstreamer的新手,我想通过网络通过mpeg2-ts流网络摄像头视频.我可以使用以下管道流式传输视频,但是我不知道如何使用mpegmux
与mpeg2-ts进行流式传输.任何帮助将是巨大的!谢谢.
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.
我的工作路线(没有mpegmux
):
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
我尝试了以下类似方法,但仍无法使它正常工作.发件人给出错误无法将rtph264pay与mux链接",接收方给出了无法将udpsrc与mux链接".
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
请注意,我在接收器中使用tsdemux
而不是mpegtsdemux
,因为它将输出'no element"mpegtsdemux"'.但是,如果键入$ gst-inspect-1.0 mpegtsdemux
,它会打印:
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
我不知道为什么gst-launch-1.0找不到mpegtsdemux
.
I have no idea why gst-launch-1.0 can't find mpegtsdemux
.
感谢@otopolsky,我找到了一个可以正常工作的管道(见下文).而且,如果将tsparse
放在tsdemux
之前,他/她也不必在接收器中使用大写字母.
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
还有几个问题:
- 为什么我不需要在接收方添加
rtpmp2tdepay
? (如果我将其添加到管道中的任何位置,则会生成无法将rtpmp2tdepay与xx链接".) - 流视频的质量将比不使用
mpegtsmux
的流质量差.这是为什么?是因为它使用mpeg2-ts吗?有提高流媒体质量的技巧吗?
- 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?
推荐答案
您必须这样做:
x264enc ! mpegtsmux ! rtpmp2tpay ! udpsink
类似于此答案.
tsdemux是元素,而mpegtsdemux是包含此元素的插件.如检查消息中所述,它还包含tsparse ..也许如果您在tsdemux之前使用tsparse,则不需要有关接收器中上限的额外信息(我对此不太确定).
The tsdemux is element however mpegtsdemux is plugin containing this element. It also contains tsparse as noted in inspect's message.. maybe if you use tsparse before tsdemux you dont need extra information about the caps in receiver(I am not exactly sure about this).
另一个提示:如果您使用zerolatency
,它将丢弃速度预设或任何其他质量处理.
Another hint for you: if you use zerolatency
it will discard the speed preset or any other quality handling.
HTH
这篇关于如何在Gstreamer中使用mpegtsmux进行网络摄像头流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!