Raspberry Pi‎ > ‎SANKI Device‎ > ‎

Camera

Camera



    This post will show step by step how to Stream the content captured by your RaspberryPI Camera, these are the things we will be doing in this tutorial to get everything set and running.

- Connect Camera to RaspberryPi.
- Enable Camera in RaspberryPi Configuration file.
- Install VLC program in RaspberryPi
- Excute Streaming command specifying communication protocol and port.

So, the first step to take is connecting your RaspberryPi Camera Module properly, take on count that the camera is easily affected by static so make sure to avoid that, also it should be connected to the socket right behind the Ethernet Port and pay special attention that the connector’s strip is fully inserted and making clean contact as shown in the picture below:


Now that we have our camera properly connected its time to enable it “if not already enabled” in the RaspberryPi configuration file, so you need to open a new Command Terminal and execute the following command:

1
sudo raspi-config


After enabling the camera make sure to reboot the RaspberryPi, when rebooting is completed the camera is fully set and ready to be used, now we need to download the package that will perform the live streaming functionality, getting it is as simple as just executing this command in your RPi Command Terminal:


1
sudo apt-get install vlc

Once the vlc package is installed we can stream the content using the following command:


1
raspivid -o - -t 0 -hf -w 800 -h 400 -fps 24 |cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8160}' :demux=h264

This command starts recording using the camera and sets the output size to be 800 width and 400 height with a rate of 24 frames per second then pipes the output to cvlc to stream the content using http access protocol in the port 8160 using the encoding video format h.264, the video is ready to be consumed in the location “http://raspberrypi.ip:8160/”

This video shows how to do it yourself:

To play live streaming in your PC there’s a VLC Client you can download fromhttp://www.videolan.org/vlc/, in case you want to see it on your Android Device you can either go for VLC Android Client Application from Google Play or download at the bottom of this post the source code of the Player I created for the demonstration and modify this line in MainActivity class:


1
mMediaPlayer.setDataSource("http://raspberrypi.ip:8160/");

Android Player Source Code: RaspberryPiCameraStream



Pi Vision


RUN before connect Pi Camera
  • $ chmod 755 rpiCC
  • $ ./rpiCC

Simple Way

  • Run on Raspberry Pi : raspivid -o - -t 0 -w 300 -h 200 -n | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264
  • Run On MXPlayer or VLC : rtsp://192.168.11.12:8554

Reference