我正在尝试通过 IP 将我的网络摄像头从一台 PC 流式传输到另一台 PC。这都是通过命令行完成的。首先我尝试:
#gst 启动 v4l2src !xvimagesink
哪个工作正常并启动网络摄像头并显示图片/视频。然后我尝试通过 udp 将网络摄像头流式传输到另一台 PC。
gst-launch v4l2src device=/dev/video0 ! 'video/x-raw-yuv,width=320,height=240' ! x264enc pass=qual quantizer=20 tune=zerolatency ! rtph264pay ! udpsink host=127.0.0.1 port=1234 sync=false
在目标 PC 上,我开始执行此操作:
gst-launch -v udpsrc port=1234 ! fakesink dump=1
我在外壳中看到的位置:
00000000 (0x7f2ebc004a70): 80 e0 18 2b 7a 74 25 94 2b 28 22 2d 5c 41 73 0c ...+zt%.+("-\As.
00000010 (0x7f2ebc004a80): a5 12 72 91 4b 97 36 f6 8f 12 46 d9 45 5f cf ac ..r.K.6...F.E_..
00000020 (0x7f2ebc004a90): 92 80 33 35 c2 65 37 d5 f0 1e f0 70 d6 95 b2 3d ..35.e7....p...=
00000030 (0x7f2ebc004aa0): 52 82 53 f7 fe 47 be 62 30 39 e9 97 c9 bb 56 de R.S..G.b09....V.
00000040 (0x7f2ebc004ab0): b1 d3 eb d0 f1 49 90 7b bc 23 9b 9f ab 1e ee 72 .....I.{.#.....r
00000050 (0x7f2ebc004ac0): ff 61 41 ac 8e 54 b9 96 16 ba 4d 37 f6 67 8e ce .aA..T....M7.g..
00000060 (0x7f2ebc004ad0): 1a 8b 6b 9a 06 f0 31 51 25 e2 b0 a6 73 55 23 76 ..k...1Q%...sU#v
00000070 (0x7f2ebc004ae0): 02 e8 97 60 ec 77 52 1d 3d 1c 55 52 5c 24 5a fb ...`.wR.=.UR\$Z.
00000080 (0x7f2ebc004af0): ae 6f d7 bb 0a 18 bf bb 72 43 7e c2 76 ab fc ca .o......rC~.v...
00000090 (0x7f2ebc004b00): ba dd a0 e5 f5 ea 61 2b 1c 77 da ab 44 62 4f 60 ......a+.w..DbO`
000000a0 (0x7f2ebc004b10): 78 83 d3 1a 54 f7 a9 af 15 4b db 08 6d 43 31 a5 x...T....K..mC1.
所以在我看来,它正在流式传输图像。现在,我尝试在屏幕上显示它。我用这个显示流:
gst-launch -v udpsrc port=1234 ! application/x-rtp,clockrate=90000,payload=96 ! rtph264depay queue-delay=0 ! ffdec_h264 ! xvimagesink
但它不显示网络摄像头;而是在外壳中我得到:
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, clockrate=(int)90000, payload=(int)96, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264
/GstPipeline:pipeline0/GstRtpH264Depay:rtph264depay0.GstPad:src: caps = video/x-h264
/GstPipeline:pipeline0/GstRtpH264Depay:rtph264depay0.GstPad:sink: caps = application/x-rtp, clockrate=(int)90000, payload=(int)96, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264
/GstPipeline:pipeline0/ffdec_h264:ffdec_h2640.GstPad:sink: caps = video/x-h264
/GstPipeline:pipeline0/ffdec_h264:ffdec_h2640.GstPad:src: caps = video/x-raw-yuv, width=(int)320, height=(int)240, framerate=(fraction)30/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
ERROR: from element /GstPipeline:pipeline0/GstUDPSrc:udpsrc0: Internal data flow error.
Additional debug info:
gstbasesrc.c(2543): gst_base_src_loop (): /GstPipeline:pipeline0/GstUDPSrc:udpsrc0:
streaming task paused, reason not-negotiated (-4)
Execution ended after 79200858888 ns.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
/GstPipeline:pipeline0/ffdec_h264:ffdec_h2640.GstPad:src: caps = NULL
/GstPipeline:pipeline0/ffdec_h264:ffdec_h2640.GstPad:sink: caps = NULL
/GstPipeline:pipeline0/GstRtpH264Depay:rtph264depay0.GstPad:src: caps = NULL
/GstPipeline:pipeline0/GstRtpH264Depay:rtph264depay0.GstPad:sink: caps = NULL
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = NULL
Setting pipeline to NULL ...
Freeing pipeline ...
我不知道我做错了什么。所有这些都在 CentOS 6.3 上,我在其中安装了 GStreamer 10.29,其中包含所有插件(基本、好、坏、丑)和 gstreamer-ffmpeg,两者都来自存储库http://pkgrepo.linuxtech.net/el6/release/linuxtech。回购。