Raspberry Pi/Camera streaming: Difference between revisions

From Wiki
No edit summary
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
* latency increases strongly when vlc or cvlc is used
== direct udp stream ==
== direct udp stream ==
* Raspi with camera
* Raspi with camera
Line 49: Line 50:
</blockquote>
</blockquote>


== direct tcp stream with netcat==
* Raspi with camera
<blockquote>
<pre>
raspivid -a 12 -t 0 -w 1920 -h 1080 -vf -ih -fps 25 -l -o - | nc -k -l 5000
</pre>
</blockquote>


* PC with monitor
<blockquote>
<pre>
mplayer -x 1280 -y 720 -geometry 0:0 -fps 200 -demuxer h264es -noborder ffmpeg://tcp://192.168.111.173:5000
</pre>
</blockquote>


== rtsp stream ==
== rtsp stream (big latency) ==
* Raspi with camera
* Raspi with camera
<blockquote>
<blockquote>
Line 73: Line 87:
</blockquote>
</blockquote>


== dual output (direct low latency + rtsp big latency) ==
* Raspi with camera
<blockquote>
<pre>
mkfifo video.stream
raspivid -a 12 -t 0 -w 1280 -h 720 -hf -ih -fps 30 -o - | tee video.stream | cvlc -v stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264 | nc 192.168.1.20 5000 < video.stream
</pre>
</blockquote>
* Raspi with monitor
<blockquote>
<pre>
mkfifo video.stream
nc -l -p 5000 > video.stream | omxplayer --win 0,0,800,480 video.stream
</pre>
</blockquote>


== gstreamer ==
== gstreamer ==
* apt install gstreamer1.0-tools
* apt install gstreamer1.0-tools gstreamer1.0-plugins-bad gstreamer1.0-plugins-good gstreamer1.0-libav
 
* Raspi with camera (test)
<blockquote>
<pre>
raspivid -n -w 1280 -h 720 -b 4500000 -fps 30 -vf -hf -t 0 -o - | gst-launch-1.0 -v fdsrc !  h264parse ! tee name=splitter ! queue ! rtph264pay config-interval=10 pt=96 ! udpsink host=192.168.1.101 port=9000 splitter. ! queue ! filesink location="videofile.h264"
</pre>
</blockquote>
 
* Raspi with monitor (test)
<blockquote>
<pre>
gst-launch-1.0 -v udpsrc port=9000 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false
 
</pre>
</blockquote>
 
== Resolutions ==
* 1920 x 1080
* 1296 x 972 (full view)
* 1270 x 720




== Links ==
== Links ==
* https://raspberrypi.stackexchange.com/questions/26675/modern-way-to-stream-h-264-from-the-raspberry-cam
* https://raspberrypi.stackexchange.com/questions/26675/modern-way-to-stream-h-264-from-the-raspberry-cam
* https://chriscarey.com/blog/2017/04/30/achieving-high-frame-rate-with-a-raspberry-pi-camera-system/comment-page-1/
* https://raspberrypi.stackexchange.com/questions/27082/how-to-stream-raspivid-to-linux-and-osx-using-gstreamer-vlc-or-netcat
* https://raspberrypi.stackexchange.com/questions/27041/record-and-stream-video-from-camera-simultaneously
* https://community.ubnt.com/t5/UniFi-Video/Tutorial-RTSP-Raspberry-Pi-B-Viewer-6-Cam-4-Cam/td-p/1536448
* https://serverfault.com/questions/386261/save-the-stream-to-mp4-files
* https://superuser.com/questions/766437/capture-rtsp-stream-from-ip-camera-and-store

Latest revision as of 20:30, 24 January 2018

  • latency increases strongly when vlc or cvlc is used

direct udp stream

  • Raspi with camera
raspivid -a 12 -t 0 -w 1280 -h 720 -hf -ih -fps 30 -o udp://192.168.1.10:5000

-a 12        # annotate
-t 0         # timeout disabled (default=5s)
-w 1280      # width
-h 720       # height
-hf          # horizontal flip
#-vf         # vertical flip
-ih          # insert inline headers to stream
-fps 30      # frames per second
-0 udp://192.168.1.10:5000    # send stream to ip:port
  • Raspi with monitor
omxplayer --win 0,0,800,480 udp://@:5000

-win 0,0,800,480    # position of video window


direct tcp stream

  • Raspi with camera
raspivid -a 12 -t 0 -w 1280 -h 720 -vf -ih -fps 30 -l -o tcp://0.0.0.0:5000
  • Raspi with monitor
omxplayer --win 0,0,800,480 tcp://192.168.1.20:5000
  • vlc with monitor
tcp/h264://192.168.1.20:5000

direct tcp stream with netcat

  • Raspi with camera
raspivid -a 12 -t 0 -w 1920 -h 1080 -vf -ih -fps 25 -l -o - | nc -k -l 5000
  • PC with monitor
mplayer -x 1280 -y 720 -geometry 0:0 -fps 200 -demuxer h264es -noborder ffmpeg://tcp://192.168.111.173:5000

rtsp stream (big latency)

  • Raspi with camera
raspivid -t 0 -n -b 1000000 -g 30 -ih -pf baseline -w 640 -h 480 -fps 30 -o - | cvlc -v stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264
  • Raspi with monitor
omxplayer --win 0,0,800,480 rtsp://192.168.1.20:8554/
  • vlc with monitor
rtsp://192.168.111.182:8554/

dual output (direct low latency + rtsp big latency)

  • Raspi with camera
mkfifo video.stream
raspivid -a 12 -t 0 -w 1280 -h 720 -hf -ih -fps 30 -o - | tee video.stream | cvlc -v stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264 | nc 192.168.1.20 5000 < video.stream
  • Raspi with monitor
mkfifo video.stream
nc -l -p 5000 > video.stream | omxplayer --win 0,0,800,480 video.stream

gstreamer

  • apt install gstreamer1.0-tools gstreamer1.0-plugins-bad gstreamer1.0-plugins-good gstreamer1.0-libav
  • Raspi with camera (test)
raspivid -n -w 1280 -h 720 -b 4500000 -fps 30 -vf -hf -t 0 -o - | gst-launch-1.0 -v fdsrc !  h264parse ! tee name=splitter ! queue ! rtph264pay config-interval=10 pt=96 ! udpsink host=192.168.1.101 port=9000 splitter. ! queue ! filesink location="videofile.h264"
  • Raspi with monitor (test)
gst-launch-1.0 -v udpsrc port=9000 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false

Resolutions

  • 1920 x 1080
  • 1296 x 972 (full view)
  • 1270 x 720


Links