Full width home advertisement

Arduino project

Raspberry project

Post Page Advertisement [Top]

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
make
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
make
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
BindAddress 0.0.0.0
# 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.
NoDaemon

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

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

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





31 comments:

  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,

    ReplyDelete
    Replies
    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.

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

    ReplyDelete
  3. Hello :) I try to do this tutorial. I following instructions and when i try to run this i get this :
    https://zapodaj.net/0585c6b0d18fd.png.html
    Someone can help me ?

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

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

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

      Delete
    4. i Have raspbeery pi 3 with raspian 10 jessie

      Delete
    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

      Delete
    6. what version of raspian wheeze or jessie ?

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

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

    ReplyDelete
  5. should U be concerned about about deprecated warning during the make portion of install the ffmpeg?

    ReplyDelete
  6. Is this a tailored ffmpeg just for web video streaming for a fully functioning install of ffmpeg?

    I have several Raspberry Pi Zero W's with camera modules running as time lapse cameras collecting images around my home. Currently I run ffmpeg on my Mac Mini to convert the jpeg images to a video clip for the day. This works fine. But I would like to automate the process and use a Raspberry Pi 3 to run ffmpeg via crontab to create the videos rather than manually running ffmpeg on my Mac.

    Will your build of ffmpeg allow me to do this?

    Thanks,
    Mike

    ReplyDelete
  7. is it possible to stream the video at an IP address without the '/test.mjpg'? Just the IP addr and Port number.
    With this I have no problem to stream it, but i need to further use it in a python code and I am using server socket to read it and it is only allowing me to enter an IP addr and port number. I cant find a way to add '/test.mjpg' to the addr it listens to. Any suggestions?

    ReplyDelete
    Replies
    1. unfortunately i have no experience about this. Please try to search more

      Delete
    2. HI, today i find another way stream video no need "/test.mjpg", just using IP address and port number only
      Please visit here
      http://engineer2you.blogspot.com/2016/05/raspberry-local-ip-webcam-usb.html

      Delete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Nicely Explained!
    I got -> "Unable to find a suitable output format for 'http://localhost:8090/feed1.ffm' http://localhost:8090/feed1.ffm: Invalid argument"
    ERROR! Can you help?

    Command -> $ ffserver -f /etc/ffserver.conf & ffmpeg -s 600x480 -f video4linux2 -i /dev/video0 http://localhost:8090/feed1.ffm

    Output->ffmpeg version N-90077-g56f77b0 Copyright (c) 2000-2018 the FFmpeg developers
    built with gcc 4.9.2 (Raspbian 4.9.2-10)
    configuration: --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree --enable-libtheora --enable-libvorbis
    libavutil 56. 7.101 / 56. 7.101
    libavcodec 58. 11.101 / 58. 11.101
    libavformat 58. 9.100 / 58. 9.100
    libavdevice 58. 1.100 / 58. 1.100
    libavfilter 7. 12.100 / 7. 12.100
    libswscale 5. 0.101 / 5. 0.101
    libswresample 3. 0.101 / 3. 0.101
    libpostproc 55. 0.100 / 55. 0.100
    ffserver version N-87073-g1c56bec Copyright (c) 2000-2017 the FFmpeg developers
    built with gcc 4.9.2 (Raspbian 4.9.2-10)
    configuration:
    libavutil 55. 74.100 / 55. 74.100
    libavcodec 57.103.101 / 57.103.101
    libavformat 57. 78.100 / 57. 78.100
    libavdevice 57. 7.101 / 57. 7.101
    libavfilter 6.100.100 / 6.100.100
    libswscale 4. 7.103 / 4. 7.103
    libswresample 2. 8.100 / 2. 8.100
    /etc/ffserver.conf:1: Port option is deprecated. Use HTTPPort instead.
    /etc/ffserver.conf:3: BindAddress option is deprecated. Use HTTPBindAddress instead.
    /etc/ffserver.conf:9: NoDaemon option has no effect. You should remove it.
    /etc/ffserver.conf:27: Setting default value for video bit rate tolerance = 20000. Use NoDefaults to disable it.
    /etc/ffserver.conf:27: Setting default value for video rate control equation = tex^qComp. Use NoDefaults to disable it.
    /etc/ffserver.conf:27: Setting default value for video max rate = 30906320. Use NoDefaults to disable it.
    /etc/ffserver.conf:27: Setting default value for video buffer size = 160000. Use NoDefaults to disable it.
    [video4linux2,v4l2 @ 0x1fe71f0] The V4L2 driver changed the video from 600x480 to 640x480
    Input #0, video4linux2,v4l2, from '/dev/video0':
    Duration: N/A, start: 16778.275190, bitrate: 147456 kb/s
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 147456 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
    [NULL @ 0x1fe8e60] Unable to find a suitable output format for 'http://localhost:8090/feed1.ffm'
    http://localhost:8090/feed1.ffm: Invalid argument
    [4]- Exit 1 ffserver -f /etc/ffserver.conf

    ReplyDelete
    Replies
    1. Hi, please try to update/ uprade Raspberry and then do all above steps again.

      Delete
    2. I have also this problem.
      ->Unable to find a suitable output format for 'http://localhost:8090/feed1.ffm'
      http://localhost:8090/feed1.ffm: Invalid argument
      Have you already solved it?

      Delete
  10. Thanks for the great tutorial! I have a Raspberry pi model 3, and cannot seem to get this to work. When I go to install ffmpeg, it installs without a problem, but when I try to execute the webcam.sh file, it says that the ffserver is not a recognized command. I have tried to configure ffmpeg with "--arch=armhf", but that did not seem to work. Do you have any suggestions?

    ReplyDelete
    Replies
    1. Can i see the error code? Maybe you need to open port forwarding 8090?

      Delete
    2. Thanks for the fast reply. After working with the system for a few hours, I decided to use your tutorial for the moving camera and use motion to broadcast the camera signal. I used this with your same car webpage, and it works great. One note on the camera.php file - every user needs to change the file to their specific IP address, or it will listen for the camera output on the right port, but the wrong IP address, or at least this was the case for me. Thank you for the tutorials, as they were very helpful and informative!

      Delete
  11. Hello, thank you very much for your tutorial! It worked perfectly, but I have one question. Do you know or have an idea on how to implement the stream on a website? I am running an Apache Server on the raspberry and i would like to implement the stream onto it.

    ReplyDelete
    Replies
    1. Hi, i didn't stream to (internet) website by ffmpeg.
      I just did it by another application, and use "Port Forwarding" to put it into internet.
      Please see here http://engineer2you.blogspot.com/2016/05/raspberry-local-ip-webcam-usb.html

      Delete

Bottom Ad [Post Page]