GStreamer-从Raspberry到VLC-PC的网络摄像头流 [英] GStreamer - Webcam stream from Raspberry to VLC-PC

查看:176
本文介绍了GStreamer-从Raspberry到VLC-PC的网络摄像头流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用gstreamer 1.0将网络摄像头视频从Raspberry传输到VLC播放器. 现在,我得到了以下用于Raspberry的命令:

gst-launch-1.0 -vv -e v4l2src device=/dev/video0  \
! videoscale \
! "video/x-raw,width=352,height=288,framerate=10/1" \
! queue  \
! x264enc \
! h264parse \
! rtph264pay config-interval=10 pt=96 \
! udpsink host=239.255.12.42 port=5004

和以下sdp文件一起使用vlc播放流:

c=IN IP4 239.255.12.42
m=video 5004 RTP/AVP 96
a=rtpmap:96 H264/90000

当我运行gst-launch-1.0命令时,我可以通过wireshark看到它正在发送udp数据包,但是当我尝试使用vlc和sdp文件播放流时却什么也没得到. VLC日志显示:

es error: cannot peek
es error: cannot peek
live555 error: no data received in 10s, aborting

我不知道怎么了.我可能没有正确构建管道,这就是为什么VLC无法将流识别为正确的视频流的原因.有什么想法吗?

预先感谢您的帮助.

解决方案

VLC可以将ts流与RTP协议结合使用.该方法是在mpegtsmux之后使用rtp有效负载,它将对生成的ts缓冲区(数据包)进行有效负载.

所以代替这个:

src ! queue ! x264enc ! h264parse ! rtph264pay ! udpsink

您可以执行以下操作:

src ! queue ! x264enc ! h264parse ! mpegtsmux ! rtpmp2tpay ! udpsink

然后在vlc中仅使用rtp://@:port 这样,mpegtsmux将封装有关其包含的流

的信息.

我应该注意,您的方法是不正确的,它甚至可能更有效(mpegtsmux会将视频切成188字节数据包,但您的方法将切成〜1400字节的udp数据包),但是您需要为vlc提供正确的SDP文件以便流式传输. 例如,例如,但是我对此没有太多经验. >

这是您当前使用的管道:

gst-launch-1.0 -vv -e v4l2src device=/dev/video0 ! "video/x-raw,width=352,height=288,framerate=25/1"\ ! queue ! x264enc speed-preset=1 ! h264parse ! mpegtsmux ! rtpmp2tpay ! udpsink host=192.255.10.41 port=5004

使用零延迟时,您可能会获得更好的结果:

x264enc tune=4这样,它将丢弃所有其他质量参数,例如速度预设等.

这是有关调整属性的文档:

tune : Preset name for non-psychovisual tuning options
       flags: readable, writable
       Flags "GstX264EncTune" Default: 0x00000000, "(none)"
       (0x00000001): stillimage       - Still image
       (0x00000002): fastdecode       - Fast decode
       (0x00000004): zerolatency      - Zero latency

I'm trying to stream webcam video from a Raspberry to a VLC player using gstreamer 1.0. Right now i got the following command for the Raspberry:

gst-launch-1.0 -vv -e v4l2src device=/dev/video0  \
! videoscale \
! "video/x-raw,width=352,height=288,framerate=10/1" \
! queue  \
! x264enc \
! h264parse \
! rtph264pay config-interval=10 pt=96 \
! udpsink host=239.255.12.42 port=5004

And the following sdp file to play the stream with vlc:

c=IN IP4 239.255.12.42
m=video 5004 RTP/AVP 96
a=rtpmap:96 H264/90000

When i run the gst-launch-1.0 command i can see with wireshark that it is sending udp packets but when i try to play the stream with vlc and the sdp file i get nothing. The vlc log says:

es error: cannot peek
es error: cannot peek
live555 error: no data received in 10s, aborting

I don't know what's wrong. I probably have'nt build the pipeline properly and that's why the vlc does not recognize the stream as a proper video stream. Any ideas?

Thanks in advance for your help.

解决方案

VLC understand ts stream combined with RTP protocol. The approach is to use rtp payloader after mpegtsmux which will payload the generated ts buffers (packets).

So instead of this:

src ! queue ! x264enc ! h264parse ! rtph264pay ! udpsink

You can do this:

src ! queue ! x264enc ! h264parse ! mpegtsmux ! rtpmp2tpay ! udpsink

And then use just rtp://@:port in vlc In this way the mpegtsmux will encapsulate information about what streams does it contains

I should note that your approach is not incorrect, and could be even more effective (mpegtsmux will slice video into 188 Byte packets, but your approach will slice into ~ 1400 Bytes udp packets), but you need to provide correct SDP file for vlc in order to stream it. For example like this but I do not have much experience with this..

So this is your current pipe which works:

gst-launch-1.0 -vv -e v4l2src device=/dev/video0 ! "video/x-raw,width=352,height=288,framerate=25/1"\ ! queue ! x264enc speed-preset=1 ! h264parse ! mpegtsmux ! rtpmp2tpay ! udpsink host=192.255.10.41 port=5004

You can maybe achieve better results when using zerolatency:

like this x264enc tune=4 it will discard all other quality parameters like speed-preset etc..

This is from docs about tune property:

tune : Preset name for non-psychovisual tuning options
       flags: readable, writable
       Flags "GstX264EncTune" Default: 0x00000000, "(none)"
       (0x00000001): stillimage       - Still image
       (0x00000002): fastdecode       - Fast decode
       (0x00000004): zerolatency      - Zero latency

这篇关于GStreamer-从Raspberry到VLC-PC的网络摄像头流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆