Im trying to stream video from a Raspberry Pi (on Raspbian) to a Windows 7 PC like in this video: https://www.youtube.com/watch?v=lNvYanDLHZA
我正在尝试从一个树莓派(对树莓派)流视频到Windows 7电脑,就像这个视频:https://www.youtube.com/watch?v=lNvYanDLHZA
I have a Logitech C270 connected to the Raspberry Pi, and have managed to stream webcam video over TCP using:
我有一个Logitech C270连接到树莓Pi,并且已经成功地使用了TCP使用的webcam视频:
gst-launch v4l2src device=/dev/video0 ! \
'video/x-raw-yuv,width=640,height=480' ! \
x264enc pass=qual quantizer=20 tune=zerolatency ! \
rtph264pay ! tcpsink host=$pi_ip port=5000
from my Pi. Receive this using VLC works, but with a 3 sec delay. I want to do this over UDP to get a shorter delay (correct me if I'm wrong). But cannot for the life of me figure it out. I have tried following:
从我的π。使用VLC工作接收这个,但是延迟3秒。我想在UDP上做这个,以得到更短的延迟(如果我错了,请纠正我)。但我的生活不能解决这个问题。我试过:
gst-launch-1.0 v4l2src device=/dev/video0 ! \
'video/x-raw-yuv,width=640,height=480' ! \
x264enc pass=qual quantizer=20 tune=zerolatency ! \
rtph264pay ! udpsink host=$pc_ip port=1234
and
和
gst-launch-1.0 udpsrc port=1234 ! \
"application/x-rtp, payload=127" ! \
rtph264depay ! ffdec_h264 ! fpsdisplaysink sync=false text-overlay=false
For the Pi and PC side, respectively (taken from Webcam streaming using gstreamer over UDP) but with no luck. (tried to change the video/x-raw-yuv to fit 1.0 version but still without luck)
对于Pi和PC端(分别来自使用UDP上的gstreamer的网络摄像头流),但运气不好。(尝试将视频/x-raw-yuv修改为适合1.0版本,但仍然没有成功)
Any hints would be highly appreciated!
如有任何提示,我们将不胜感激!
Edit
编辑
With the raspi camera (not the webcam) the following works:
与树莓相机(不是网络摄像头)以下工作:
Windows batch script:
Windows批处理脚本:
@echo off
cd C:\gstreamer\1.0\x86_64\bin
gst-launch-1.0 -e -v udpsrc port=5000 ! application/x-rtp, payload=96 !
rtpjitterbuffer ! rtph264depay ! avdec_h264 ! fpsdisplaysink sync=false
text-overlay=false
Raspberry Pi Bash Script:
覆盆子πBash脚本:
#!/bin/bash
clear
raspivid -n -t 0 -rot 270 -w 960 -h 720 -fps 30 -b 6000000 -o - | gst-
launch-1.0 -e -vvvv fdsrc ! h264parse ! rtph264pay pt=96 config-interval=5 !
udpsink host=***YOUR_PC_IP*** port=5000
But I cannot figure out how to use to webcam instead of the raspberry pi camera (i.e. v4l2src instead of raspivid) in the same manner
但是我不知道如何用网络摄像头代替覆盆子圆周率相机(v4l2src而不是raspivid)
Edit 2
编辑2
The following works, but is very slow and has a huge delay:
以下是一些有效的方法,但是非常缓慢,并且有很大的延迟:
RPi
零售物价指数
gst-launch-1.0 -vv -e v4l2src device=/dev/video0 \
! videoscale \
! "video/x-raw,width=400,height=200,framerate=10/1" \
! x264enc pass=qual quantizer=20 tune=zerolatency \
! h264parse \
! rtph264pay config-interval=5 pt=96 \
! udpsink host=$myip port=$myport
PC:
PC:
gst-launch-1.0 -e -v udpsrc port=5001 ! ^
application/x-rtp, payload=96 ! ^
rtpjitterbuffer ! ^
rtph264depay ! ^
avdec_h264 ! ^
autovideosink sync=false text-overlay=false
I now suspect that (thanks to hint from @Mustafa Chelik) that the huge lag is due to the fact that the raspberry pi has to encode the webcam video, while the raspberry pi video is already encoded, not sure if this makes sense though?
我现在怀疑(感谢mustafa Chelik的提示),之所以会有这么大的延迟,是因为树莓派(raspberry pi)必须对摄像头视频进行编码,而树莓派(raspberry pi)的视频已经被编码了,不确定这是否有意义?
2 个解决方案
#1
2
Found hints to the solution from http://www.z25.org/static/rd/videostreaming_intro_plab/
从http://www.z25.org/static/rd/videostreaming_intro_plab/找到解决方案的提示
The following worked very well for streaming video from Logitech c270 on raspberry pi to a windows 7 pc:
以下是Logitech c270在raspberry pi上传输到windows 7 pc上的视频:
PC side:
电脑:
gst-launch-1.0 -e -v udpsrc port=5001 ! ^
application/x-rtp, encoding-name=JPEG,payload=26 ! ^
rtpjpegdepay ! jpegdec ! ^
autovideosink
RPi side:
零售物价指数:
gst-launch-1.0 -v v4l2src device=/dev/video0 \
! "image/jpeg,width=1280, height=720,framerate=30/1" \
! rtpjpegpay \
! udpsink host=$myip port=$myport
I suspect that it was the encoding of the webcam video to h264 that was too slow on the raspberry pi, however the webcamera already gave jpeg frames and thus no encoding was nescessary using "image/jpeg"
我怀疑是对h264编码的网络摄像机视频在raspberry pi上太慢了,但是摄像头已经给了jpeg帧,因此使用“image/jpeg”编码是不必要的
#2
1
I have used for my webcamstream the MJPG-Streamer and get a 0,2 seconds delay. http://wiki.ubuntuusers.de/MJPG-Streamer
我使用了我的webcamstream的MJPG-Streamer,并得到一个0,2秒的延迟。http://wiki.ubuntuusers.de/MJPG-Streamer
And the advantage is that you can watch it with the webbrowser.
它的优点是你可以通过网络浏览器观看。
#1
2
Found hints to the solution from http://www.z25.org/static/rd/videostreaming_intro_plab/
从http://www.z25.org/static/rd/videostreaming_intro_plab/找到解决方案的提示
The following worked very well for streaming video from Logitech c270 on raspberry pi to a windows 7 pc:
以下是Logitech c270在raspberry pi上传输到windows 7 pc上的视频:
PC side:
电脑:
gst-launch-1.0 -e -v udpsrc port=5001 ! ^
application/x-rtp, encoding-name=JPEG,payload=26 ! ^
rtpjpegdepay ! jpegdec ! ^
autovideosink
RPi side:
零售物价指数:
gst-launch-1.0 -v v4l2src device=/dev/video0 \
! "image/jpeg,width=1280, height=720,framerate=30/1" \
! rtpjpegpay \
! udpsink host=$myip port=$myport
I suspect that it was the encoding of the webcam video to h264 that was too slow on the raspberry pi, however the webcamera already gave jpeg frames and thus no encoding was nescessary using "image/jpeg"
我怀疑是对h264编码的网络摄像机视频在raspberry pi上太慢了,但是摄像头已经给了jpeg帧,因此使用“image/jpeg”编码是不必要的
#2
1
I have used for my webcamstream the MJPG-Streamer and get a 0,2 seconds delay. http://wiki.ubuntuusers.de/MJPG-Streamer
我使用了我的webcamstream的MJPG-Streamer,并得到一个0,2秒的延迟。http://wiki.ubuntuusers.de/MJPG-Streamer
And the advantage is that you can watch it with the webbrowser.
它的优点是你可以通过网络浏览器观看。