从USB网络摄像头中提取h264流(logitech C920)

时间:2017-10-26 05:39:36

标签: gstreamer gst-launch

所以,我开始玩gstreamer,我能够做非常简单的管道,如

gst-launch-1.0 -v v4l2src device=/dev/video1 ! video/x-raw,format=YUY2,width=640,height=480,framerate=10/1 ! videoconvert ! autovideosink

现在,由于我的USB网络摄像头(视频1,视频0是计算机内置的摄像头)支持h264(我已使用lsusb检查过),我想尝试获取h264提要直。据我所知,这个饲料是在mjpeg中复用的,但是在网上看看gstreamer似乎能够得到它。

由于我的最终目标是从Beaglebone流式传输,我尝试使用this post给出的解决方案(从不同的终端添加一个监听器):

#sender
gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-264,width=320,height=90,framerate=10/1 ! tcpserversink host=192.168.148.112 port=9999

但这会产生以下错误:

WARNING: erroneous pipeline: could not link v4l2src0 to tcpserversink0

我也尝试过与我的第一个命令类似的东西,将源码从raw更改为h264(基于that post,尝试给出的完整命令会给出相同的错误消息)

gst-launch-1.0 -v v4l2src device=/dev/video1 ! video/x-h264,width=640,height=480,framerate=10/1 ! h264parse ! avdec_h264 ! autovideosink

但同样,这也不起作用:

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data flow error.
Additional debug info:
gstbasesrc.c(2948): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming task paused, reason not-negotiated (-4)
Execution ended after 0:00:00.036309961
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

我承认这让我非常疯狂:在网上搜索SO或其他地方,似乎有很多人使用与我拥有的网络摄像头完全相同的工作(Logitech C920),但我一个接一个地遇到问题。

从该网络摄像头中提取h264的正确管道示例是什么?

1 个答案:

答案 0 :(得分:0)

你肯定需要在它接通电线之前使用一个payloader。例如rtph264pay。这是一个无法测试的示例,因为我没有硬件可用。如果这不能引导你朝着正确的方向前进,我可以使用替代来源的udp示例。

服务器

gst-launch v4l2src device=/dev/video1 \
! video/x-264,width=320,height=90,framerate=10/1 \
! x264enc \
! queue \
! rtph264pay, config-interval=3, pt=96, mtu=1500 \
! queue \
! tcpserversink host=127.0.0.1 port=9002

<强>客户端

gst-launch tcpserversrc host=127.0.0.1 port=9002 \
! application/x-rtp, media=video, clock-rate=90000, encoding-name=H264, payload=96 \
! rtph264depay \
! video/x-h264 \
! queue \
! ffdec_h264 \
! queue \
! xvimagesink