Rasbperry pi - FFmpeg install and stream to web

Monday, October 10, 2016

Following tutorial will show how to install FFmpeg into Raspberry Pi, then stream video to Local web which can be access through Computer/Phone/Tablet

1. Install library
cd /usr/src
git clone git://git.videolan.org/x264
cd x264
./configure --host=arm-unknown-linux-gnueabi --enable-static --disable-opencl
sudo make install

2. Install ffmpeg
cd /usr/src
git clone git://source.ffmpeg.org/ffmpeg.git
cd ffmpeg/
sudo ./configure --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree
Note: Model B+ (4-Cores) can do “make -j4” instead of  “make”
         This "make" command will take 4 hours long -> take a sleep instead wait for it!
sudo make install

3. Config something:
gedit /etc/ffserver.conf

Input following settings:
Port 8090
# bind to all IPs aliased or not
# max number of simultaneous clients
MaxClients 10
# max bandwidth per-client (kb/s)
MaxBandwidth 1000
# Suppress that if you want to launch ffserver as a daemon.

<Feed feed1.ffm>
File /tmp/feed1.ffm
FileMaxSize 10M

<Stream test.mjpg>
Feed feed1.ffm
Format mpjpeg
VideoFrameRate 4
VideoSize 600x480
VideoBitRate 80
# VideoQMin 1
# VideoQMax 100
Strict -1

Make execute file for easy command
gedit /usr/sbin/webcam.sh
Input following settings:
ffserver -f /etc/ffserver.conf & ffmpeg -v verbose -r 5 -s 600x480 -f video4linux2 -i /dev/video0 http://localhost:8090/feed1.ffm

Change mode for file webcam.sh so it can execute, then run it
chmod +x /usr/sbin/webcam.sh

After above command, streamming will be started to Local web

Go to web browser, type address <your-ip-address:8090>/test.mjpg
Result will come:

Note: to stop camera, press Ctrl+C at terminal, then type command
pkill ffserver

As test, video can see clock needle rotate every single second!

4. Autmatic run
In order to run ffmpeg service without type command /usr/sbin/webcam.sh
Go to /etc/rc.local -> then add command line /usr/sbin/webcam.sh before "exit 0"
Everytime Raspberry start up, ffmpeg will automatically run without typing code

You might also like:
1. Raspberry pi - remote control car camera
This project will make remote car control which can view camera attached on car.
It will need:
Hardware side:
1. Car toy
2. Two gear motor
3. Raspberry B+
4. Wifi dongle
5. Power bank (10A) (for Raspberry board)
6. Battery (for gear motor)
7. H-bridge circuit (L298N)


  1. Thanks for the step-by-step information. I am curious, what is the lagging in this video. I tried different projects for video streaming and they always have about 3 sec lagging. thanks,

    1. Hi, i have just updated video recording clock and local web. I admit that there is still some lagging, anyway, this is the best i have now.
      Thanks for visiting.

  2. Thanks. Maybe helps to someone: if is used a Raspberry Camera attached to the GPU, before the ffmpeg commnand you need to enable the camera in raspi-config and then load the driver with modprobe bcm2835-v4l2 , so /dev/video0 will appear.

  3. Hello :) I try to do this tutorial. I following instructions and when i try to run this i get this :
    Someone can help me ?

    1. and one more question. This file ffserver.conf we could make or this file should be already created ?

    2. Hi. We (manually) made the file ffserver.conf
      Make sure USB camera is plug to Raspberry (check if /dev/video0 is exist or not).
      Try it again with every single steps as in instruction.

    3. I think , propably my camera doesnt support a raspberry PI (camera is a some kind of chineese no name )

    4. i Have raspbeery pi 3 with raspian 10 jessie

    5. I did this with 2 webcam, one is no name, one is Logitech. Both are also from China, but they're working well. Mine is Rasp2 Raspian

    6. what version of raspian wheeze or jessie ?

    7. I have just made it in RASPBIAN JESSIE latest version. Everything still works fine.

  4. Is it possible to record a vídeo and save it into a usb memory styck ?



Search This Blog

Most Reading

Google+ Followers