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).

8090 is the port you assign.

Now you can play the stream video at http:<Raspberry Pi IP>:8090

(reference: http://raspi.tv/2013/how-to-stream-video-from-your-raspicam-to-your-nexus-7-tablet-using-vlc)

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).

If you can develop Android app, you can play it on VideoView. Refer to my another blog: Android-er - Play stream video (from Raspberry Pi) on VideoView, with APK download.



Updated@2016-07-06:
- Re-test on Raspberry Pi 3 + Camera Module V2 NoIR + Raspbian Jessie, play in Windows 10 + VLC Media Player and Android App with VideoView (with APK download).


4 comments:

Unknown said...

Can you tell me how to stream video from raspberry pi 2 to a windows computer which has vncserver to access the pi

Unknown said...

Hello,
I want to record a video stream from a IPCam to hard disk connected to raspberryPI. How should I do it? I am using FOSCAM FI8918W

Unknown said...

Great Post.
Do you have any ideia why I have the following error?

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

Thanks in advance.

Unknown said...

Can anyone guide me how to create .sh files in raspbian?