Mjpg-Streamer
Hi all,
This is my first post on the forums, so sorry if I miss a few things out!
Ok, my overall intent is to build a robot using the raspberry pi, so I will need a webcam stream and the GPIO to control the motors. I have managed to get the GPIO working, however I am struggling to find a way of streaming the webcam (ps2 eyetoy on /dev/video0) with minimal delay, which I want to get working before I setup anything else!
I have already tried to use motion, to stream the video, however I have had a delay of over 2 seconds, which would be unusable for my purpose, so I did some searching and found a thread on another forum which pointed me to mjpg-streamer. (http://sourceforge.net/projects/mjpg-streamer/). This is designed for low powered devices and other people have used it for this purpose, however I have had issues trying to install it. I would really appreciate it if someone could share a set of instructions of exactly how to install this on a pi, including dependencies, or an alternative method.
Thanks very much,
Tom
(just to let you know, but i a using debian)
This is my first post on the forums, so sorry if I miss a few things out!
Ok, my overall intent is to build a robot using the raspberry pi, so I will need a webcam stream and the GPIO to control the motors. I have managed to get the GPIO working, however I am struggling to find a way of streaming the webcam (ps2 eyetoy on /dev/video0) with minimal delay, which I want to get working before I setup anything else!
I have already tried to use motion, to stream the video, however I have had a delay of over 2 seconds, which would be unusable for my purpose, so I did some searching and found a thread on another forum which pointed me to mjpg-streamer. (http://sourceforge.net/projects/mjpg-streamer/). This is designed for low powered devices and other people have used it for this purpose, however I have had issues trying to install it. I would really appreciate it if someone could share a set of instructions of exactly how to install this on a pi, including dependencies, or an alternative method.
Thanks very much,
Tom
(just to let you know, but i a using debian)
Re: Mjpg-Streamer
Thanks very much for the quick response, however.....
I tried this as soon as I got home from school, but I had a couple of issues, firstly, about every other frame was either black or badly distorted making the feed very hard to interpret (I have heard of some issues with the eyetoy-ps2 webcam http://www.raspberrypi.org/phpBB3/viewt ... 08&p=98239), and I also still had a delay of about 1.5s
Any more ideas?
Thanks
Tom
I tried this as soon as I got home from school, but I had a couple of issues, firstly, about every other frame was either black or badly distorted making the feed very hard to interpret (I have heard of some issues with the eyetoy-ps2 webcam http://www.raspberrypi.org/phpBB3/viewt ... 08&p=98239), and I also still had a delay of about 1.5s
Any more ideas?

Thanks
Tom
Re: Mjpg-Streamer
I believe VLC can be used to stream video. No idea how well it'd work on the RaspberryPi or with an EyeToy camera though... or what delay you'd get...
Re: Mjpg-Streamer
Getting MJPG-streamer working under Raspberry Pi would be a major breakthrough in usability. IP camera for $35 is significant. However I am sure the source will not compile so we need a guru help here to make it work under Raspberry Pi
All the other streamers are just inadequate comparison to MJPG-streamer. That thing just works.
All the other streamers are just inadequate comparison to MJPG-streamer. That thing just works.
Re: Mjpg-Streamer
Other people have reported that they do have mjpg-streamer working http://www.raspberrypi.org/phpBB3/searc ... g+streamer
So maybe if you could report what compile errors you're getting...
So maybe if you could report what compile errors you're getting...

Re: Mjpg-Streamer
I had ffmpeg streaming with a pretty small delay on Raspbian.
less than a second IIRC.
Use the sources from deb-multimedia.org rather than the ones in the repos.
less than a second IIRC.
Use the sources from deb-multimedia.org rather than the ones in the repos.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044
Re: Mjpg-Streamer
Yep, I am also desperately trying to do this.
Motion is incredibly intensive, using most of the webcam bandwidth...dismiss.
ffstream is very customisable but impossible to set up (at least to me!)
mjpeg-streamer is very easy but I can't get it to install on debian wheezy (videodev.h not found, think it's to do with it using v4l found on squeeze and not the v4l2 on wheezy?? confirm/deny?)
Anyone got any ideas?
My aim:
Expose webcam ('/dev/video0') to http://localhost:port
Thanks
Simon
Motion is incredibly intensive, using most of the webcam bandwidth...dismiss.
ffstream is very customisable but impossible to set up (at least to me!)
mjpeg-streamer is very easy but I can't get it to install on debian wheezy (videodev.h not found, think it's to do with it using v4l found on squeeze and not the v4l2 on wheezy?? confirm/deny?)
Anyone got any ideas?
My aim:
Expose webcam ('/dev/video0') to http://localhost:port
Thanks
Simon
Re: Mjpg-Streamer
Grab deb-multimedia ffmpeg sourcehowroyd wrote:Yep, I am also desperately trying to do this.
Motion is incredibly intensive, using most of the webcam bandwidth...dismiss.
ffstream is very customisable but impossible to set up (at least to me!)
mjpeg-streamer is very easy but I can't get it to install on debian wheezy (videodev.h not found, think it's to do with it using v4l found on squeeze and not the v4l2 on wheezy?? confirm/deny?)
Anyone got any ideas?
My aim:
Expose webcam ('/dev/video0') to http://localhost:port
Thanks
Simon
then follow this guide http://sirlagz.net/?p=357
The bitrate and videosize etc can be changed to suit your setup.
I'll probably write up a RasPi specific way of doing this later too.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044
Re: Mjpg-Streamer
No luck.
Compiled as per instructions here: http://www.raspberrypi.org/phpBB3/viewt ... =66&t=9045
All ok, no errors.
Made a file /etc/ffserver.conf which contains:
Then ran:
It pauses, then returns to "pi@raspberrypi:~$ ".
Inspection of processes using "top" show nothing of the above running, and pidof ffserver ad pidof ffmpeg both return nothing.
Help!
Compiled as per instructions here: http://www.raspberrypi.org/phpBB3/viewt ... =66&t=9045
All ok, no errors.
Made a file /etc/ffserver.conf which contains:
Code: Select all
Port 81
BindAddress 0.0.0.0
MaxClients 10
MaxBandwidth 50000
NoDaemon
file webcam.ffm
FileMaxSize 10M
Feed webcam.ffm
Format mjpeg
VideoSize qvga
VideoFrameRate 10
VideoBitRate 100
Code: Select all
pi@raspberrypi:~$ sudo ffserver -f /etc/ffserver.conf & ffmpeg -v 2 -r 5 -s 320x240 -f video4linux2 -i /dev/video0 http://localhost:81/webcam.ffm
Inspection of processes using "top" show nothing of the above running, and pidof ffserver ad pidof ffmpeg both return nothing.
Help!
Re: Mjpg-Streamer
change -v 2 to -v verbose
and then report back what happens.
-v 2 used to work but not anymore, I need to update that guide actually.
Also, I've updated a few other things in that post.
Wordpress stripped a few pretty important tags which I didn't notice
Shows how many people actually read my blog haha...
and then report back what happens.
-v 2 used to work but not anymore, I need to update that guide actually.
Also, I've updated a few other things in that post.
Wordpress stripped a few pretty important tags which I didn't notice



Shows how many people actually read my blog haha...
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044
Re: Mjpg-Streamer
Yes it's a brilliant guide, best I've found after hours on google!
Looks like and IO error, not a clue what this means with my limited knowledge!
Looks like and IO error, not a clue what this means with my limited knowledge!
Code: Select all
pi@raspberrypi:~$ sudo ffserver -f /etc/ffserver.conf & ffmpeg -v verbose -r 5 -s 320x240 -f video4linux2 -i /dev/video0 http://localhost:81/webcam.ffm
[1] 1673
ffmpeg version 0.11.1 Copyright (c) 2000-2012 the FFmpeg developers
built on Aug 3 2012 10:57:11 with gcc 4.6.3
configuration:
libavutil 51. 54.100 / 51. 54.100
libavcodec 54. 23.100 / 54. 23.100
libavformat 54. 6.100 / 54. 6.100
libavdevice 54. 0.100 / 54. 0.100
libavfilter 2. 77.100 / 2. 77.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 15.100 / 0. 15.100
[video4linux2,v4l2 @ 0x197e520] [3]Capabilities: 4000001
ffserver version 0.11.1 Copyright (c) 2000-2012 the FFmpeg developers
built on Aug 3 2012 10:57:11 with gcc 4.6.3
configuration:
libavutil 51. 54.100 / 51. 54.100
libavcodec 54. 23.100 / 54. 23.100
libavformat 54. 6.100 / 54. 6.100
libavdevice 54. 0.100 / 54. 0.100
libavfilter 2. 77.100 / 2. 77.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 15.100 / 0. 15.100
[video4linux2,v4l2 @ 0x197e520] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 117.112620, bitrate: 6144 kb/s
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 320x240, 6144 kb/s, 5 tbr, 1000k tbn, 5 tbc
[http @ 0x197ec10] HTTP error 404 Not Found
http://localhost:81/webcam.ffm: Input/output error
pi@raspberrypi:~$
Re: Mjpg-Streamer
Changed ffserver.conf to the below, now works fine through VLC.
Struggling receiving it in html though to embed it in my webpage, what's the best way? use img tags or iframe?
Struggling receiving it in html though to embed it in my webpage, what's the best way? use img tags or iframe?
Port 81
BindAddress 0.0.0.0
MaxClients 10
MaxBandwidth 50000
NoDaemon
<Feed webcam.ffm>
file /tmp/webcam.ffm
FileMaxSize 10M
</Feed>
<Stream webcam.mjpeg>
Feed webcam.ffm
Format mjpeg
VideoSize qvga
VideoFrameRate 10
VideoBitRate 100
</Stream>
Re: Mjpg-Streamer
I would use an iframe, easiest way to do it.
Is this going to be an internet facing one or just for your local network ?
Just as an aside - I've written up a guide specific for the Raspberry Pi.
Hopefully this helps someone else too
http://sirlagz.net/?p=493
Is this going to be an internet facing one or just for your local network ?
Just as an aside - I've written up a guide specific for the Raspberry Pi.
Hopefully this helps someone else too
http://sirlagz.net/?p=493
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044
Re: Mjpg-Streamer
Network side initially but might open it up internet side; its part of an academic research project so would only be open at certain times
-
- Posts: 9
- Joined: Mon Aug 27, 2012 8:44 pm
Re: Mjpg-Streamer
mjpg-streamer is available as a package on Arch Linux ARM:ds18s20 wrote:Getting MJPG-streamer working under Raspberry Pi would be a major breakthrough in usability. IP camera for $35 is significant. However I am sure the source will not compile so we need a guru help here to make it work under Raspberry Pi
All the other streamers are just inadequate comparison to MJPG-streamer. That thing just works.
Code: Select all
pacman -S mjpg-streamer
Code: Select all
apt-get install subversion
apt-get install libv4l-dev
apt-get install libjpeg8-dev
apt-get install imagemagick
libv4l-dev and libjpeg8-dev are required dependencies.
ImageMagick will be needed for the installation, since it is used to process some image files during the compilation. (This is a bad move by the developers, IMHO).
Now to do the compilation (as root, or sudo):
Code: Select all
svn co https://mjpg-streamer.svn.sourceforge.net/svnroot/mjpg-streamer mjpg-streamer
cd mjpg-streamer/mjpg-streamer
make USE_LIBV4L2=true clean all
make DESTDIR=/usr install
Code: Select all
mjpg_streamer -i "/usr/lib/input_uvc.so -d /dev/video0 -r 640x480 -f 1" -o "/usr/lib/output_http.so -p 8090 -w /var/www/mjpg_streamer"
-d specifies the device
-r is resolution
-f is frame rate
-y specifies YUYV format, rather than MJPEG format.
Output modifiers:
-p is port
-w is web serving directory.
See the documentation for more details.
Mjpg-streamer includes a lightweight web server, so you will not need to run apache or lighttpd. I think this is a wrong idea, but there it is.
A typical line in the html file for displaying an image stream looks like this:
Code: Select all
<img src="http://192.168.0.63:8090/?action=stream" width="752">
Some webcams will deliver MJPEG images. Mjpg-streamer is very efficient with these webcams, as it just reads the images and streams them to the web. I am seeing CPU usage of ~ 1% with a 640x360 resolution MJPEG image.
If you camera does not deliver MJPEG, you can probably still read it with the YUYV format, but there is more CPU overhead, because the software must read the YUYV and convert it to MJPEG in order to stream it.
If you don't know what formats your webcam delivers, try experimenting with fswebcam in "--verbose" mode. I found fswebcam to very useful for characterizing my cameras, and figuring out which resolutions they will serve. fswebcam reads an image from a webcam and writes it to a file. You can then see under what conditions it failed, and whether the files are garbled or not. (Files may be garbled if the resolution is somehow screwed up.) Fswebcam is available on both Arch and Wheezy as a package.
The best alternative to mjpg-streamer seems to be motion coupled with a web server like apache or lighttpd. Motion is very sophisticated software intended for surveillance video. Most of my effort in configuring it was spent turning off options I am not using.
On wheezy, I think motion's handling of MJPEG format from the webcam may be broken. That's a minor annoyance. MJPEG is at least 20 times more efficient in terms of size and bandwidth than YUYV, so if you want to go to higher resolution, MJPEG may work where YUYV fails. I was streaming 1280x960 resolution from a Logitech C310, at low frame rates.
Re: Mjpg-Streamer
CrystalCowboy
Thanks a _lot_. That post describes it all and it works perfectly!
I did use slightly different command line parameters.
Using a HP 3110 I have 12.50fps solid at 1280x720 with 5% cpu usage (overclocked @ 1ghz)
Thanks a _lot_. That post describes it all and it works perfectly!

I did use slightly different command line parameters.
Code: Select all
mjpg_streamer -i "./input_uvc.so -f 15 -r 1280x720" -o "./output_http.so -w ./www"
-
- Posts: 55
- Joined: Fri Jun 22, 2012 10:16 pm
Re: Mjpg-Streamer
Yeah, thanks a lot CrystalCowboy, that's exactly what I needed!
(I'm leaving the -w bit off, as I don't need an extra webpage served)
(I'm leaving the -w bit off, as I don't need an extra webpage served)
Re: Mjpg-Streamer
Thanks a lot for this, CrystalCowboy.
The key point I originally missed was to add the -y parameter to input command. But it realy uses CPU when the camera can't provide jpeg directly.
I am using:
./mjpg_streamer -i "./input_uvc.so -y -d /dev/video0 -r 640x480 -f 10 -q 100 -n" -o "./output_http.so -n"
And that takes about 95% of CPU from my 1000 arm_freq turbo overclocked RPi.
The key point I originally missed was to add the -y parameter to input command. But it realy uses CPU when the camera can't provide jpeg directly.
I am using:
./mjpg_streamer -i "./input_uvc.so -y -d /dev/video0 -r 640x480 -f 10 -q 100 -n" -o "./output_http.so -n"
And that takes about 95% of CPU from my 1000 arm_freq turbo overclocked RPi.
Re: Mjpg-Streamer
I tried out mjpg-streamer. A resolution of 960*720 with 15 frames / s results in a CPU load of 7-8 % when using MJPG-images from the webcam. This is very good, so the next problem is to get motion detection working. Has anyone tried using the mjpg-streamer output as input for motion on a different machine?
Even better would be to have motion running reliably on the Raspberry Pi also with larger frame sizes or to use the GPU for motion detection.
Even better would be to have motion running reliably on the Raspberry Pi also with larger frame sizes or to use the GPU for motion detection.
Re: Mjpg-Streamer
I tested another Logitech webcam which can go to 1600*1200 in MJPEG-mode, but for some reason streaming works very slow with this webcam with the 960*720 resolution which works fine with my older Logitech webcam. The CPU load was very low and I did not see any error messages, but in the browser the refresh rate of the images was one frame occasionally instead of 5 or 10 frames / s. I could test this on a PC, to see if the problem can be reproduced or not.
Re: Mjpg-Streamer
Hi,
I'm also looking for solution for mjpg-streamer output as input for motion to record video on a different machine. Anyone has experience on this & what is the command to use for motion to record video whenever there is activities detected ?
Thanks
I'm also looking for solution for mjpg-streamer output as input for motion to record video on a different machine. Anyone has experience on this & what is the command to use for motion to record video whenever there is activities detected ?
Thanks
-
- Posts: 117
- Joined: Wed Sep 05, 2012 12:43 pm
Re: Mjpg-Streamer
I got the source to compile, invoked Mjpg-streamer, and the light on my webcam shows that it is active.
Yet, whenever I go to my PC, and try to log in to the Pi's webserver (located at 192.168.1.214), I get nothing. I can get to the Pi at that address using Putty.
Should I be doing something else?
Yet, whenever I go to my PC, and try to log in to the Pi's webserver (located at 192.168.1.214), I get nothing. I can get to the Pi at that address using Putty.
Should I be doing something else?
-
- Posts: 44
- Joined: Tue Feb 05, 2013 9:19 pm
- Location: Bristol, UK
Re: Mjpg-Streamer
apologies if this is a huge bump...
i have followed all the instructions to the letter with this, the libs, subversion and imagemagick are all the newest versions
but when i enter this line;
i get
using the pre-mentioned wheezy, and i've been using it for less than 24 hours, and i've installed LOADS of random packages, so it may be one of those bad boys?
i have followed all the instructions to the letter with this, the libs, subversion and imagemagick are all the newest versions
but when i enter this line;
Code: Select all
svn co https://mjpg-streamer.svn.sourceforge.net/svnroot/mjpg-streamer mjpg-streamer
Code: Select all
svb: E000013: Can't make directory '/mjpg-streamer': Permission denied
Re: Mjpg-Streamer
Where are you running that command from ?
Try adding sudo to the front of that command.
Try adding sudo to the front of that command.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044