使用gstreamer通过UDP从网络摄像头流式传输

时间:2016-05-29 14:59:56

标签: command-line-interface gstreamer

我试图通过以下方式使用gstreamer从webcamera流式传输

gst-launch-1.0 -e -v v4l2src device=/dev/video0 ! image/jpeg, width=1920, height=1080, framerate=30/1  ! rtpjpegpay ! udpsink host=127.0.0.1 port=1234

并接受此

gst-launch-1.0 -e -v udpsrc port=1234 caps="application/x-rtp,payload=26,media=video,clock-rate=90000, encoding-name=JPEG, a-framerate=30/1, ssrc=459305186, timestamp-offset=2045518475, seqnum-offset=13040, height=1920, width=1080" ! rtpjpegdepay ! jpegdec ! avimux ! filesink location=swag.avi

使用GST_DEBUG运行= avimux:5产生

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = "application/x-rtp\,\ payload\=\(int\)96\,\ media\=\(string\)video\,\ clock-rate\=\(int\)90000\,\ encoding-name\=\(string\)JPEG"
/GstPipeline:pipeline0/GstRtpJPEGDepay:rtpjpegdepay0.GstPad:sink: caps = "application/x-rtp\,\ payload\=\(int\)96\,\ media\=\(string\)video\,\ clock-rate\=\(int\)90000\,\ encoding-name\=\(string\)JPEG"
/GstPipeline:pipeline0/GstRtpJPEGDepay:rtpjpegdepay0.GstPad:src: caps = "image/jpeg\,\ framerate\=\(fraction\)0/1\,\ width\=\(int\)1920\,\ height\=\(int\)1080"
0:00:00.049099661 18712      0x1d34230 DEBUG                 avimux gstavimux.c:415:gst_avi_mux_vidsink_set_caps:<avimux0> avimux0:video_0, caps=image/jpeg, framerate=(fraction)0/1, width=(int)1920, height=(int)1080
0:00:00.049145352 18712      0x1d34230 WARN                  avimux gstavimux.c:641:gst_avi_mux_vidsink_set_caps:<avimux0> refused caps image/jpeg, framerate=(fraction)0/1, width=(int)1920, height=(int)1080
0:00:00.059443752 18712      0x1d34230 DEBUG                 avimux gstavimux.c:415:gst_avi_mux_vidsink_set_caps:<avimux0> avimux0:video_0, caps=image/jpeg, framerate=(fraction)0/1, width=(int)1920, height=(int)1080
0:00:00.059564217 18712      0x1d34230 WARN                  avimux gstavimux.c:641:gst_avi_mux_vidsink_set_caps:<avimux0> refused caps image/jpeg, framerate=(fraction)0/1, width=(int)1920, height=(int)1080
0:00:00.059662942 18712      0x1d34230 DEBUG                 avimux gstavimux.c:415:gst_avi_mux_vidsink_set_caps:<avimux0> avimux0:video_0, caps=image/jpeg, framerate=(fraction)0/1, width=(int)1920, height=(int)1080
0:00:00.059727807 18712      0x1d34230 WARN                  avimux gstavimux.c:641:gst_avi_mux_vidsink_set_caps:<avimux0> refused caps image/jpeg, framerate=(fraction)0/1, width=(int)1920, height=(int)1080
0:00:00.059997284 18712      0x1d34230 DEBUG                 avimux gstavimux.c:415:gst_avi_mux_vidsink_set_caps:<avimux0> avimux0:video_0, caps=image/jpeg, framerate=(fraction)0/1, width=(int)1920, height=(int)1080
ERROR: from element /GstPipeline:pipeline0/GstUDPSrc:udpsrc0: Internal data flow error.
0:00:00.060125073 18712      0x1d34230 WARN                  avimux gstavimux.c:641:gst_avi_mux_vidsink_set_caps:<avimux0> refused caps image/jpeg, framerate=(fraction)0/1, width=(int)1920, height=(int)1080
Additional debug info:
gstbasesrc.c(2943): gst_base_src_loop (): /GstPipeline:pipeline0/GstUDPSrc:udpsrc0:
streaming task paused, reason not-negotiated (-4)        
0:00:00.060335173 18712      0x1d34230 DEBUG                 avimux gstavimux.c:415:gst_avi_mux_vidsink_set_caps:<avimux0> avimux0:video_0, caps=image/jpeg, framerate=(fraction)0/1, width=(int)1920, height=(int)1080
EOS on shutdown enabled -- waiting for EOS after Error
Waiting for EOS...
0:00:00.060462445 18712      0x1d34230 WARN                  avimux gstavimux.c:641:gst_avi_mux_vidsink_set_caps:<avimux0> refused caps image/jpeg, framerate=(fraction)0/1, width=(int)1920, height=(int)1080
/GstPipeline:pipeline0/GstAviMux:avimux0.GstPad:src: caps = video/x-msvideo
/GstPipeline:pipeline0/GstFakeSink:fakesink0.GstPad:sink: caps = video/x-msvideo
0:00:00.061094793 18712      0x1d34230 DEBUG                 avimux gstavimux.c:1177:gst_avi_mux_riff_get_avi_header:<avimux0> creating avi header, data_size 4, idx_size 0
^Chandling interrupt.
Interrupt: Stopping pipeline ...
Interrupt while waiting for EOS - stopping pipeline...
Execution ended after 0:00:02.492331232
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

如果我放弃udp并直接执行此操作,它会按照我的期望/想要

工作
gst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg, width=1920, height=1080, framerate=30/1 ! rtpjpegpay ! application/x-rtp, payload=96 ! rtpjpegdepay ! avimux ! filesink location=movie.avi

只是补充一点,接受这个就像魅力一样。

gst-launch-1.0 -e -v udpsrc port=1234 caps="application/x-rtp,payload=26,media=video,clock-rate=90000, encoding-name=JPEG, a-framerate=30/1, ssrc=459305186, timestamp-offset=2045518475, seqnum-offset=13040, height=1920, width=1080" ! rtpjpegdepay ! jpegdec ! autovideosink

为什么它不能在udp上运行,我该如何解决?

1 个答案:

答案 0 :(得分:1)

虽然Prasanth的建议并不完全正确,但这是正确的想法。我后来了解到,在启动源命令时,它会为给定的组件吐出整个大写字母,例如

/GstPipeline:pipeline0/GstRtpJPEGPay:rtpjpegpay0.GstPad:src: caps = "application/x-rtp\,\ media\=\(string\)video\,\ clock-rate\=\(int\)90000\,\ encoding-name\=\(string\)JPEG\,\ a-framerate\=\(string\)30.000000\,\ payload\=\(int\)26\,\ ssrc\=\(uint\)3985523101\,\ timestamp-offset\=\(uint\)2117749493\,\ seqnum-offset\=\(uint\)21358"

通过将正确的盖子粘贴到水槽中,一切正常。