Rasbperry pi - FFmpeg install and stream to web

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

Hardware needed:
1. Rasbperry Pi https://amzn.to/2VAq8Gl
2. USB camera https://amzn.to/2T6OGoM


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)





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

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

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

    ReplyDelete
  6. Is it possible to record a vĂ­deo and save it into a usb memory styck ?

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

    ReplyDelete
  8. 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
  9. 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
  10. This comment has been removed by the author.

    ReplyDelete
  11. 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
    3. Same problem here too after updating and upgrading

      Delete
  12. 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
  13. 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
  14. every time I try to do the make command in the second step it starts running for a couple of minutes and then exits the command and doesn't finish it. it gives me this at the bottom:

    Makefile:108: recipe for target 'ffmpeg_g' failed
    make: *** [ffmpeg_g] Error 1

    how can I get passed this?

    ReplyDelete
    Replies
    1. please try to update your Raspberry Pi and do it again. Thanks

      Delete
  15. Hi, please try to update your Raspberry Pi and do it again. Now i'm busy to make this project again to see if what's problem. Thanks for your visit

    ReplyDelete
  16. This is my first visit to your web journal! We are a group of volunteers and new activities in the same specialty. Website gave us helpful data to work. Official Web site

    ReplyDelete
  17. Hi there, i was just wondering if anyone could give me any help. when i got to "sudo ./configure --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree", I get the error ERROR: libx264 not found

    If you think configure made a mistake, make sure you are using the latest
    version from Git. If the latest version fails, report the problem to the
    ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
    Include the log file "ffbuild/config.log" produced by configure as this will help
    solve the problem."

    ReplyDelete
  18. An accomplished author and sales consultant, Riddleberger is also highly in demand as a business development and motivational speaker for organizations seeking to drive their sales force to greater levels of performance Salesforce training in Chennai

    ReplyDelete
  19. Also known as CBD Oil, it is a phytocannabinoid. 40% of the extract from cannabis plants is made up of this cannabinoid. Cannabidiol is extracted from Cannabis sativa, and Cannabis indica and has been proven to help ease symptoms of various ailments.

    Visit more :- DONOR EGG | Khatrimaza | 7StarHD | Tamilrockers | FREE VPN APPS | 9XMOVIES

    ReplyDelete
  20. It is important that students should have a great command on the basic concepts which will teach them in the CBSE 12th commerce classes. It is also important that students should have proper guidance during their preparation

    Visit more :- QuickBooks Online | Google Operators | Engineering Students | Wedding Anniversary | HR assignment | Adopt Accounting Software | Real Estate Home Selling

    ---

    ReplyDelete
  21. Many Hollywood and international films were leaked on the website within days of its release, The Moviesflix online website has leaked films like Bad Boys for Life, Parasite, Dolittle, Birds of Prey etc. The website has leaked different web series that released quite recently, like Money Heist season 4, Ozark season 3, among others.

    Visit more :- roadside assistance provider | Extract Emails From Facebook | Thewatchseries | HTML TO PDF WITH PDFBEAR

    ReplyDelete
  22. Despite the Indian government has taken action against SkymoviesHD or other torrent websites, they continue to

    operate with impunity. The reason behind Filmyzillas smooth run is it keeps changing its domain name, which reduces the chances of being caught by the cybercrime.

    Visit more :- How To Make Money | Make Lots Of Money | automotive franchises opportunity | Roast

    Turkey
    | success of your business. | Small Businesses | Product

    Photography

    ReplyDelete
  23. Movierulz.plz provides a quick downloading server to its visitors. Movies are available in all qualities on Movierulz2 ms. ON Movierulz2 ms website, you will get Movierulz plz 2020 Telugu, Bollywood, Hollywood, Movierulz2 Malayalam, Kollywood, Tollywood Movies and you can download free. It is very easy to access movies on Moviesrulz2 Ms site.

    Visit more :- increase your web traffic | Make money online | JEE examinations | gestational surrogacy process | HVAC system | Glass 2019 Movie | solar power company

    ReplyDelete
  24. Website 123MKV Movies started as a small website with some movies on its page. But as time progressed, the site continued

    to release new movies and traffic increased for them. Since it has always become a piracy site, the government prohibits active URLs from making internet. But the site

    is not only smart, but also quick. They quickly change their website and update it with new dynamic URLs. Some of the current activities are as follows

    Visit more :- PERSONAL LOAN EMI | Instagram App | VEGETABLES MARKET | Gestational Surrogacy | Cranberry Brie Bites | Hotels In Copenhagen | old Smartphone

    ReplyDelete
  25. You should definitely be smart about your medical insurance. You

    pay for a service and therefore, you do want to use it. Don’t just sit on your insurance and think it is useful if something bad happens to you. Health insurance can

    play a big role in preventative healthcare as well. If you aren’t happy with your current health insurance, then consider comparing different individual health

    insurance plans options and finding one that works for you.

    Visit more :- Health benefits of turmeric | affiliate marketing | career opportunities engineering | Instagram aggregator | credit score | Winter Beauty Trends | Risk of discount broker

    ReplyDelete
  26. Box TV is a popular website that offers a large database of various types of Bollywood and Hollywood movies, TV shows, web series and other video content. However, it provides an advanced video streaming service, which means you need to pay to access its content. In addition to the website, it can also use mobile apps for iOS and Android devices. You can also watch reasonable Indian movies on this website. The interface of the site is very interactive and transparent. You can enjoy your movie experience without ads or pop-ups which makes boxTV one of the best einthusan alternatives.

    Visit more :- Thanksgiving This Year | Movie4k | Robert De Niro | Sdmoviespoint | extratorrents

    ReplyDelete
  27. If the working Extratorrents website extratorrents is blocked in your region, you can use proxies to Unblock Extratorrents and download torrents. Here, we have enlisted some ExtraTorrent proxy sites that you can visit.If you are not sure how proxies work, the proxies mentioned in our Extratorrent proxy list act as intermediate servers that hide your IP address so that you can access the website without allowing the destination website to track you.

    Visit more :- BODYBUILDING NUTRITION | Convert YouTube to MP2 | Dom Z Papieru | Selling Rolling Paper | apunkagames | extratorrents | Yoga Quotes

    ReplyDelete

  28. It is important that students should have a great command on the basic concepts which will teach them in the CBSE 12th commerce classes. It is also important that students should have proper guidance during their preparation

    Visit more :- QuickBooks Online | Google Operators | Engineering Students | Wedding Anniversary | HR assignment | Adopt Accounting Software | Real Estate Home Selling

    ReplyDelete
  29. Despite the Indian government has taken action against SkymoviesHD or other torrent websites, they continue to operate with impunity. The reason behind Filmyzillas smooth run is it keeps changing its domain name, which reduces the chances of being caught by the cybercrime.

    Visit more :- How To Make Money | Make Lots Of Money | automotive franchises opportunity | Roast Turkey | success of your business. | Small Businesses | Product Photography

    ReplyDelete
  30. Skymovieshd 2020: Everyone loves watching movies, TV shows and web series but one a few know websites where they can download all of them for free. Yes, keeping in mind those section of people, we have come up with a free movie download website called, Skymovieshd or Skymovieshd.in.


    Visit more :- Skymovieshd Skymovieshd Skymovieshd Skymovieshd

    ReplyDelete
  31. Piracy of movies, TV shows, and any copyrighted material is a malicious practice that has become prevalent over the past few decades. There are strict laws and punishments to curb and prevent piracy on digital platforms, yet every day there are numerous websites that pop up for the same. Because of websites like Extramovies professionals in the entertainment industry suffer humongous financial losses.

    Visit more :- F95Zone | TodayPk | KissCartoon | HOME LIGHTING | SD Movies Point | Moviesflix | Home Decor

    ReplyDelete
  32. India is one of the countries where a lot of pirated content is accessed despite the strong rules and regulations laid down by authorities. Websites like Moviesflix are made for illegal Hollywood movies download and to watch Hollywood movies online. The pirated content makes it difficult for the movies to make business in theatres.

    Visit more :- Moviesflix Moviesflix Moviesflix Moviesflix

    ReplyDelete
  33. AI-generated captions and real-time human interpretations are important when it comes to consuming content online as they help make event content more accessible to both diverse audiences and attendees. thank you for meeting and thank you letter for a meeting

    ReplyDelete