deety
Posts: 36
Joined: Tue Jul 16, 2013 9:04 pm

Streaming Pi Camera

Sun May 01, 2016 12:39 pm

I have been trying for ages to get a reliable, repeatable method for streaming video from the pi camera module to a pc. I have tried every system I can find on the internet and on the forums. The result is either several (like 5 or 6) seconds delayed, or I just cant get it to work. The latest I have tried uses the uv4l system that is mentioned in (more than) a few posts on line. I have one now that seems to work for stills but not for video. It involves browsing to my pi address with the addition of a port (8080) number, which then leads to what I think is the server page which allows me to select from several options. I wont go into too much detail but none of them seem to work for video. The only thing I see that works is a "delayed snapshot" option, which shows a still.
Anybody out there know of a place I can go to get what I need, without spending several months learning all about Linux and video systems in general?
Cheers

shuckle
Posts: 565
Joined: Sun Aug 26, 2012 11:49 am
Location: Finland

Re: Streaming Pi Camera

Sun May 01, 2016 12:56 pm

I am using vlc:
First I do these setups:

Code: Select all

/usr/bin/v4l2-ctl -d 0 --set-fmt-video=width=1296,height=972,pixelformat=4
/usr/bin/v4l2-ctl -d 0 -p 5
and then stream with:

Code: Select all

/usr/bin/cvlc -d v4l2:///dev/video0:chroma="H264":width=1296:height=972:fps=5 --sout="#rtp{sdp=rtsp://:8888/h264}"
Has been stable. You can watch it for example with VLC (I am using zoneminder from rtsp://192.168.254.224:8888/h264)

Note that this does not work with the new pi3, but works with the older pis.

deety
Posts: 36
Joined: Tue Jul 16, 2013 9:04 pm

Re: Streaming Pi Camera

Sun May 01, 2016 1:11 pm

Thanks for the reply, but I'm on a Pi3.
Cheers

RpiName
Posts: 712
Joined: Sat Jul 06, 2013 3:14 am

Re: Streaming Pi Camera

Sun May 01, 2016 2:15 pm

deety wrote:The latest I have tried uses the uv4l system that is mentioned in (more than) a few posts on line. I have one now that seems to work for stills but not for video.
Upgrade uv4l to the latest version and try again. There was a bug introduced with the new support for cam v2 but has been fixed promptly.

MonsterMadnessMusic
Posts: 38
Joined: Mon Apr 25, 2016 6:28 am

Re: Streaming Pi Camera

Sun May 01, 2016 3:08 pm

Hi,

are you using wifi to stream to the PC? If so, can you use a good old ethernet cable for testing purposes instead?

deety
Posts: 36
Joined: Tue Jul 16, 2013 9:04 pm

Re: Streaming Pi Camera

Sun May 01, 2016 3:26 pm

I have tried both Ethernet and wifi, and I only installed the package this morning! The problem is the advice I can find seems to rely frequently on installing packages i.e imagemagick and motion, which are no longer available using simply "apt-get install". They return errors saying that the items cant be found. I will of course update the uv4l package but I'm pretty sure I've got the lastest already.
Thanks.

deety
Posts: 36
Joined: Tue Jul 16, 2013 9:04 pm

Re: Streaming Pi Camera SOLVED

Sun May 01, 2016 3:42 pm

OK, here's weird. Before I couldn't get a stream either onto the monitor connected to the PI or on a separate pc. I changed to a different browser on the PC and the stream worked immediately (on the PC). It also began displaying on the monitor connected to the pi without using a browser. NOW both computers work fine, but the directly connected monitor displays a small window with a higher frame rate whether the browser is on or not! Anyway, thanks for the advice.

User avatar
B.Goode
Posts: 8504
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Streaming Pi Camera

Sun May 01, 2016 3:45 pm

deety wrote:the advice I can find seems to rely frequently on installing packages i.e imagemagick and motion, which are no longer available using simply "apt-get install".
This is what I get when I try a 'dry-run' of installing imagemagick using Raspbian Jessie:

Code: Select all

pi@rpi2b ~ $ sudo apt-get install imagemagick -s
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  fonts-droid ghostscript imagemagick-6.q16 imagemagick-common
  libdjvulibre-text libdjvulibre21 libgs9 libgs9-common libijs-0.35
  libjbig2dec0 liblqr-1-0 libmagickcore-6.q16-2 libmagickcore-6.q16-2-extra
  libmagickwand-6.q16-2 libnetpbm10 libpaper-utils libpaper1 libwmf0.2-7
  netpbm
Suggested packages:
  ghostscript-x imagemagick-doc autotrace enscript ffmpeg gimp gnuplot grads
  graphviz hp2xx html2ps libwmf-bin mplayer povray radiance sane-utils
  texlive-base-bin transfig ufraw-batch inkscape
The following NEW packages will be installed:
  fonts-droid ghostscript imagemagick imagemagick-6.q16 imagemagick-common
  libdjvulibre-text libdjvulibre21 libgs9 libgs9-common libijs-0.35
  libjbig2dec0 liblqr-1-0 libmagickcore-6.q16-2 libmagickcore-6.q16-2-extra
  libmagickwand-6.q16-2 libnetpbm10 libpaper-utils libpaper1 libwmf0.2-7
  netpbm
0 upgraded, 20 newly installed, 0 to remove and 0 not upgraded.
Inst fonts-droid (1:4.4.4r2-6+rpi1 Raspberry Pi Foundation:stable [all])
Inst imagemagick-common (8:6.8.9.9-5+deb8u1 Raspbian:stable [all])
Inst libdjvulibre-text (3.5.25.4-4 Raspbian:stable [all])
Inst libdjvulibre21 (3.5.25.4-4+b1 Raspbian:stable [armhf])
Inst libijs-0.35 (0.35-10 Raspbian:stable [armhf])
Inst liblqr-1-0 (0.4.2-2 Raspbian:stable [armhf])
Inst libmagickcore-6.q16-2 (8:6.8.9.9-5+deb8u1 Raspbian:stable [armhf])
Inst libmagickwand-6.q16-2 (8:6.8.9.9-5+deb8u1 Raspbian:stable [armhf])
Inst libpaper1 (1.1.24+nmu4 Raspbian:stable [armhf])
Inst libwmf0.2-7 (0.2.8.4-10.3+deb8u1 Raspbian:stable [armhf])
Inst libjbig2dec0 (0.11+20120125-1 Raspbian:stable [armhf])
Inst libgs9-common (9.06~dfsg-2+deb8u1 Raspbian:stable [all])
Inst libgs9 (9.06~dfsg-2+deb8u1 Raspbian:stable [armhf])
Inst ghostscript (9.06~dfsg-2+deb8u1 Raspbian:stable [armhf])
Inst imagemagick-6.q16 (8:6.8.9.9-5+deb8u1 Raspbian:stable [armhf])
Inst imagemagick (8:6.8.9.9-5+deb8u1 Raspbian:stable [armhf])
Inst libmagickcore-6.q16-2-extra (8:6.8.9.9-5+deb8u1 Raspbian:stable [armhf])
Inst libnetpbm10 (2:10.0-15.2 Raspbian:stable [armhf])
Inst libpaper-utils (1.1.24+nmu4 Raspbian:stable [armhf])
Inst netpbm (2:10.0-15.2 Raspbian:stable [armhf])
Conf fonts-droid (1:4.4.4r2-6+rpi1 Raspberry Pi Foundation:stable [all])
Conf imagemagick-common (8:6.8.9.9-5+deb8u1 Raspbian:stable [all])
Conf libdjvulibre-text (3.5.25.4-4 Raspbian:stable [all])
Conf libdjvulibre21 (3.5.25.4-4+b1 Raspbian:stable [armhf])
Conf libijs-0.35 (0.35-10 Raspbian:stable [armhf])
Conf liblqr-1-0 (0.4.2-2 Raspbian:stable [armhf])
Conf libmagickcore-6.q16-2 (8:6.8.9.9-5+deb8u1 Raspbian:stable [armhf])
Conf libmagickwand-6.q16-2 (8:6.8.9.9-5+deb8u1 Raspbian:stable [armhf])
Conf libpaper1 (1.1.24+nmu4 Raspbian:stable [armhf])
Conf libwmf0.2-7 (0.2.8.4-10.3+deb8u1 Raspbian:stable [armhf])
Conf libjbig2dec0 (0.11+20120125-1 Raspbian:stable [armhf])
Conf libgs9-common (9.06~dfsg-2+deb8u1 Raspbian:stable [all])
Conf libgs9 (9.06~dfsg-2+deb8u1 Raspbian:stable [armhf])
Conf ghostscript (9.06~dfsg-2+deb8u1 Raspbian:stable [armhf])
Conf imagemagick-6.q16 (8:6.8.9.9-5+deb8u1 Raspbian:stable [armhf])
Conf imagemagick (8:6.8.9.9-5+deb8u1 Raspbian:stable [armhf])
Conf libmagickcore-6.q16-2-extra (8:6.8.9.9-5+deb8u1 Raspbian:stable [armhf])
Conf libnetpbm10 (2:10.0-15.2 Raspbian:stable [armhf])
Conf libpaper-utils (1.1.24+nmu4 Raspbian:stable [armhf])
Conf netpbm (2:10.0-15.2 Raspbian:stable [armhf])
pi@rpi2b ~ $
I see no reason why re-running this without the -s argument would not do an installation as expected.

Have you done

Code: Select all

sudo apt-get update
recently? You certainly need to do so after installing a new version of Raspbian before trying to install any new packages.

But that might be a distraction: I have had success streaming from an RPi with a camera module using the mjpeg-streamer package. Maybe you don't need the 2 packages you mention.


[Follow-up: obviously overtaken by progress made by @Deety, but left here in case it helps others who follow this thread.]

michaelf
Posts: 15
Joined: Sun Nov 16, 2014 2:38 pm

Re: Streaming Pi Camera

Tue May 03, 2016 9:55 am

I have a similar problem as I wish to stream video from my Pi camera to my MacBook Pro (El Capitan) with minimal latency via an Ethernet connection. I have been following an article " Low Latency Raspberry Pi Video Streaming" by Zachary Bears (http://www.zacharybears.com) but this requires me to install "Netcat" and "MPlayer" on my Mac. This has been proving to be extremely problematic !!!! Since both of these applications have been around a while, I wondered if there are any more modern replacements, suitable for the Mac. I would be grateful for any steer in the right direction.

Thanks

Mickf

linux_author
Posts: 248
Joined: Sat Apr 02, 2016 7:04 pm
Location: Gulf of Mexico
Contact: Website

Re: Streaming Pi Camera

Tue May 03, 2016 10:53 am

this works for me on my RPi3 w/Raspian and the Arduino 5MP Arducam OV5647 (Pi-cam clone?):

raspivid -o - -t 0 -hf -w 640 -h 360 -fps 25 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554}' :demux=h264

then i simply run vlc on the remote computer using the network stream address:

rtsp://rpi_with_camera_ip_address:8554/

fabulously easy!

willie
on the video-streaming Gulf of Mexico

RpiName
Posts: 712
Joined: Sat Jul 06, 2013 3:14 am

Re: Streaming Pi Camera

Tue May 03, 2016 11:02 am

michaelf wrote:I wondered if there are any more modern replacements, suitable for the Mac.
use the browser:
http://linux-projects.org

michaelf
Posts: 15
Joined: Sun Nov 16, 2014 2:38 pm

Re: Streaming Pi Camera

Tue May 03, 2016 2:17 pm

linux_author wrote:this works for me on my RPi3 w/Raspian and the Arduino 5MP Arducam OV5647 (Pi-cam clone?):

raspivid -o - -t 0 -hf -w 640 -h 360 -fps 25 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554}' :demux=h264

then i simply run vlc on the remote computer using the network stream address:

rtsp://rpi_with_camera_ip_address:8554/

fabulously easy!

willie
on the video-streaming Gulf of Mexico


Hi Willie,
thanks for the prompt (and helpful) reply. I have been down this route before and gave it up as the response on my Mac was very erratic and the delay was horrendous (5 seconds or more) and the image simply disappeared after s short period. I tried again since you have been good enough to reply but now when I open VLC and try to connect to the network stream it simply reports unable to connect to the chosen address. I have tried using both an Ethernet link and Wi-Fi ( the two computers are only feet apart at present) but to no effect.
My primary concern is latency which is why I tried the quoted article by Zach Bears and why I initially did not pursue the VLC route.
My receiving computer is a MacBook Pro running OSX El Capitan.
Thanks again and any further thoughts?
MickF

michaelf
Posts: 15
Joined: Sun Nov 16, 2014 2:38 pm

Re: Streaming Pi Camera

Tue May 03, 2016 3:13 pm

Hi Willie,
just to let you know that after a bit of digging and head scratching, my problem is not with VLC at all but with IP addressing. I have been trying to implement a direct Ethernet link between my Pi and Mac and have not sorted out static addressing properly. If I route all Ethernet traffic via my router and let DHCP sort it all out, it works. I still get 3-4 seconds delay but that is another problem.
Thanks again for your help.
Mick F

deadite66
Posts: 5
Joined: Sun Jan 31, 2016 1:24 pm

Re: Streaming Pi Camera

Tue May 03, 2016 4:14 pm

started using uv4l and h264_v4l2_rtspserver to stream h264 on my V2 cam module and found it been pretty good.
around 1 to 2 seconds of lag.

Code: Select all

sudo uv4l --sched-rr --driver raspicam --auto-video_nr --encoding h264 --width 1269 --height 730 --hflip --vflip
creates /dev/video0

Code: Select all

cd ~/h264_v4l2_rtspserver
./h264_v4l2_rtspserver -W 1269 -H 730 -F 30 -P 8554 /dev/video0
starts the rtsp stream going.

stream is watchable on rtsp://rpiaddress:8554/unicast

[http://www.linux-projects.org/modules/ ... rtspserver

RpiName
Posts: 712
Joined: Sat Jul 06, 2013 3:14 am

Re: Streaming Pi Camera

Tue May 03, 2016 6:53 pm

deadite66 wrote:started using uv4l and h264_v4l2_rtspserver to stream h264 on my V2 cam module and found it been pretty good.
around 1 to 2 seconds of lag.
with native uv4l solutions (e.g. janus,jitsi or p2p) it's typically ~200-300ms audio+video (in both directions). e.g.

https://www.youtube.com/watch?v=ODQOC5V ... oQwvCcUOph

https://www.youtube.com/watch?v=ICyVH4u ... ph&index=3

the above is an old example,now it's even better.

mattmiller
Posts: 2106
Joined: Thu Feb 05, 2015 11:25 pm

Re: Streaming Pi Camera

Wed May 04, 2016 12:11 am

raspivid -o - -t 0 -hf -w 640 -h 360 -fps 25 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554}' :demux=h264
:-)

Just for others info - this needs vlc installing on your Pi

Code: Select all

sudo apt-get update
sudo apt-get install vlc
It sometimes gives me errors but re-running it eventually works

Also - I removed the -hf parameter so that the image the camera points at is the right way round

shuckle
Posts: 565
Joined: Sun Aug 26, 2012 11:49 am
Location: Finland

Re: Streaming Pi Camera

Thu May 19, 2016 10:15 am

ok, I got this working also with jessie by adding :demux=h264.
But indeed it does not work always. And as it never failed with the wheeze and now it seems to be working about 1 time when tried 10 times....It would be really nice to understand what causes the failure and how it could be changed to work always.

shuckle
Posts: 565
Joined: Sun Aug 26, 2012 11:49 am
Location: Finland

Re: Streaming Pi Camera

Thu May 19, 2016 10:19 am

What is also interesting is that when the streaming starts, it seems to work reliably. I have run it for several days. The only problem is how to get it started always.

Maybe it is vlc, no idea.

Return to “Camera board”