Tuesday, May 5, 2015

Stream Raspberry Pi Camera Module video using raspivid and vlc

Here show how to stream video from Raspberry Pi Camera Module to network using raspivid and vlc.

Run on Raspberry Pi 2/Raspbian

View on desktop Ubuntu with VLC Media Player

- for sure, you have to enable camera module in your Raspberry Pi/Raspbian setup.

- install vlc:
$ sudo apt-get install vlc

- Run the command in Terminal, or you can make a sh file (remember to make it runnable):
$ raspivid -o - -t 99999 -w 640 -h 360 -fps 25|cvlc stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8090}' :demux=h264

Where 99999 is the length of the video, 99.999 seconds. You can change that to whatever you like. If you change it to 0 (zero) it will carry on indefinitely. (And CTRL+C to kill it at any time).

In my case, report error of "Invalid PCR value in ES_OUT_SET_(GROUP_)PCR !" Just ignore it, the stream video is playing, and show on RPi main monitor.

Tested on desktop Ubuntu, it can be played with VLC Media Player. On Android devices, Nexus 7 (2012) running Android 5.1, and Samsung Galaxy S3 running Android 4.3, it can be played using MX Player, but not VLC Player (black screen).

VLC is not supposed to be run as root. Sorry.If you need to use real-time priorities and/or privileged TCP portsyou can use /usr/bin/vlc-wrapper (make sure it is Set-UID root andcannot be run by non-trusted users first).