demonmaestro
Posts: 21
Joined: Fri Jun 07, 2013 10:07 am

How To Install Mjpg-Streamer

Sun Jun 30, 2013 4:36 am

I know this has gone over and over before on how to install but there is no actual Good information on how to install it and it WORK. I am having issues getting this to work my self.. When i get this working right i will make a video of install and instructions on how to properly install Mjpg-Streamer hassle free!

What i have
Raspberry Pi with Raspbian “wheezy”
Logitech c270
4gb card

what i got so far from a very fresh install

Code: Select all

sudo apt-get update
sudo apt-get upgrade
wget http://lilnetwork.com/download/raspberrypi/mjpg-streamer.tar.gz
tar xvzf mjpg-streamer.tar.gz
sudo apt-get install libjpeg8-dev
sudo apt-get install imagemagick
cd mjpg-streamer/mjpg-streamer
make
./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www"
and that should get you up and going!


dave_dave_dave
Posts: 1
Joined: Sun Sep 22, 2013 9:01 pm

Re: How To Install Mjpg-Streamer

Sun Sep 22, 2013 9:21 pm

Whoops, I assumed this would work when pulling down the latest file directly from the Sourceforge page for the project - but no. Compile error.

The Sourceforge versions are years old - the linked version in the post above actually does have more recent code. Use that and you'll be fine.

Or if you're adventurous, there's a few more recent updates here. Use the 'Download Snapshot' link to grab them. (Note: I haven't tested these ones, use at your own risk.)
http://sourceforge.net/p/mjpg-streamer/ ... erimental/

ricgal
Posts: 4
Joined: Tue Jul 16, 2013 5:33 pm

Re: How To Install Mjpg-Streamer

Mon Sep 30, 2013 11:45 pm

There is now a good experimental version on github. Follow this discussion at http://www.raspberrypi.org/phpBB3/viewt ... 9&p=414053 and access jacksonliam's version on github. The page is https://github.com/jacksonliam/mjpg-streamer and just download the zip file (This download is found over on the right side of the page). It has some of the software for the raspicam built in so you do not have to run raspivid or raspistill.

It works well for viewing over the lan. However, it does not seem to work over the web, so if you have an answer please message me directly.

I saved a script to launch the program. I named the following script run-raspicam-stream , saved it on my desktop, and made it executable.

Code: Select all

cd /usr/local/src/mjpg-streamer-master/mjpg-streamer-experimental
export LD_LIBRARY_PATH=.
./mjpg_streamer -i "input_raspicam.so" -o "output_http.so -w ./www/"
The line:

Code: Select all

cd /usr/local/src/mjpg-streamer-master/mjpg-streamer-experimental
changes directory to the location of the program. If you install mjpg-streamer-experimental somewhere else, then the line needs to be changed to reflect that location.

Editing raspian files on a linux host computer:

(If you are using ubuntu or another linux version on your main computer, you can load the raspian sd card in a card reader and do these edits in that system. I forget the manual way to make a file executable, so I used nautilus on ubuntu to change run-raspicam-stream to executable. This can be done in the permissions section of the file properties.)

Opening nautilus on your host computer with root file access:

(Note that some actions in nautilus require root permissions. Open the terminal window and use

Code: Select all

sudo nautilus
to run nautilus with root privileges. By doing this, you can open any file owned by root, and still be able to save your edits. )

rsd-pi
Posts: 1
Joined: Mon Oct 07, 2013 4:18 pm

Re: How To Install Mjpg-Streamer

Mon Oct 07, 2013 4:26 pm

After you have successfully run mjpg-streamer
with something like /usr/bin/mjpg_streamer -i "input_uvc.so -d /dev/video0" -o "output_http.so -p 8080 -w /var/www"
Check to see it its listening on the port desired using netstat: "netstat -anl | grep 8080" and that checks out,
You can test using VLC or a web browser using the following:
http://127.0.0.1:8080/?action=stream.

Hope this helps.

RSGURU7
Posts: 1
Joined: Tue Nov 05, 2013 8:25 am

Re: How To Install Mjpg-Streamer

Tue Nov 05, 2013 8:40 am

Hi Boss,
When i execute start.h file getting this error.
Need ur help in this!! PLS HELP
I have used ZEBRONIC camera connected directly to PI.

Error:
JPG Streamer Version: svn rev:
i: Using V4L2 device.: /dev/video0
i: Desired Resolution: 640 x 480
i: Frames Per Second.: 5
i: Format............: MJPEG
Unable to set format: 1196444237 res: 640x480
Init v4L2 failed !! exit fatal
i: init_VideoIn failed

jurmelius
Posts: 86
Joined: Sun Jul 22, 2012 7:00 pm

Re: How To Install Mjpg-Streamer

Sun Dec 01, 2013 3:41 pm

demonmaestro wrote:I know this has gone over and over before on how to install but there is no actual Good information on how to install it and it WORK. I am having issues getting this to work my self.. When i get this working right i will make a video of install and instructions on how to properly install Mjpg-Streamer hassle free!

what i got so far from a very fresh install

Code: Select all

sudo apt-get update
sudo apt-get upgrade
wget http://lilnetwork.com/download/raspberrypi/mjpg-streamer.tar.gz
tar xvzf mjpg-streamer.tar.gz
sudo apt-get install libjpeg8-dev
sudo apt-get install imagemagick
cd mjpg-streamer/mjpg-streamer
make
./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www"
ok... how do you start this? where are the parameters?
Last edited by jurmelius on Mon Dec 02, 2013 7:37 am, edited 1 time in total.

danjperron
Posts: 3391
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: How To Install Mjpg-Streamer

Mon Dec 02, 2013 2:44 am

Hi demonmaestro,

I do have the exact same camera.


And this is some of my startup script I used

full resolution 1280x720

Code: Select all

cat streamer720.sh
#cd /root/src/mjpg-streamer/mjpg-streamer
killall mjpg_streamer
/usr/local/bin/mjpg_streamer -i "/usr/local/lib/input_uvc.so -n -f 10 -r 1280x720" -o "/usr/local/lib/output_http.so -p 
10088 -w /usr/local/www" &
and this is the one I use normally

Code: Select all

cat /usr/local/bin/streamer450p.sh 
#cd /root/src/mjpg-streamer/mjpg-streamer
killall mjpg_streamer
/usr/local/bin/mjpg_streamer -i "/usr/local/lib/input_uvc.so -n -f 15 -r 800x450" -o "/usr/local/lib/output_http.so -p 10088 -w /usr/local/www" &
It is fast enough to run my RaspberryPI R/C car using a web browser on the internet.All depends of the internet access speed.

https://dl.dropboxusercontent.com/u/488 ... botCar.mpg


Don't use IExplore since it doesn't work with direct streaming. Use firefox, safari or chrome.

Open your browser and set the url to the IP of the Raspberry Pi and to the specific port of the startup script.

for me it is http://10.11.12.191:10088

Also you could use uvcdynctrl application to get information about your web camera. Very handy with the C-920 to kill the auto-focus.

uvcdynctrl -f will display all the format available on the webcam.
uvcdynctrl -c will display all control possible with your camera.

Daniel

jurmelius
Posts: 86
Joined: Sun Jul 22, 2012 7:00 pm

Re: How To Install Mjpg-Streamer

Thu Dec 19, 2013 10:39 am

Can't anybody just wrote a "dummy" innstruction on how to compile the Mjpg-Streamer from legit git/svn source and explain how to make the prosess parameterised and started as systems get booted.. Simple need..
Project is at http://sourceforge.net/projects/mjpg-streamer/

I need a MircoSoft WebCam based Mjepg/JPG ask system with basic user/id query on request.
Also timestamp written of the pic would be nice.

danjperron
Posts: 3391
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: How To Install Mjpg-Streamer

Thu Dec 19, 2013 12:49 pm

Hi Jurmelius,

The very first post is how to create the application (minus the last line).

The post just before yours , the bash script,is a script to run with 800x450 at 15 fps on port 10088.
also the web pages are located at /usr/local/www

Just use

Code: Select all

sudo nano /usr/local/bin/mystream.sh
modify what you want and save it. after just make it executable with

Code: Select all

 sudo chmod +x /usr/local/mystream.sh
type mystream.sh to run it or add the script executable into rc.local et voila

For the stamp I use ImageMagick . I’ll dig it how to do it but it is only for time lapse.

This is the last storm we got with 30cm of snow. Check the time stamp and tell me if this is what you want.

https://dl.dropboxusercontent.com/u/488 ... _12_15.mp4

For the web page time stamp, you could simply add the time using javascript.


Daniel

jurmelius
Posts: 86
Joined: Sun Jul 22, 2012 7:00 pm

How To Install Mjpg-Streamer - Dummy version

Thu Dec 19, 2013 1:01 pm

Ok.
After some massive testing, here we go again. From the beginning of Wheezy. There can be a LOT of mistakes here, but with this, mjpeg will be operational and autostarted. Log as pi user. I'm using Microsoft HD WebCam.

Install nessessary stuff

Code: Select all

sudo apt-get update
sudo apt-get install libv4l-dev libjpeg8-dev subversion imagemagick
Add missing videodev.h

Code: Select all

sudo ln -s /usr/include/linux/videodev2.h /usr/include/linux/videodev.h
Get The Mjpeg source

Code: Select all

svn co https://svn.code.sf.net/p/mjpg-streamer/code/mjpg-streamer/ mjpg-streamer
Make it

Code: Select all

cd mjpg-streamer/
make USE_LIBV4L2=true clean all
sudo make DESTDIR=/usr install
Copy stuff to Right place

Code: Select all

sudo cp mjpg_streamer /usr/local/bin
sudo cp -R www /usr/local/www
You are now ready to test the mjpg streamer.
Using the following line you start a mjpg stream at port 8080 with a
resoultion of 640×480 px - Quality 95% and 4 frames per second led to Auto. UserID and password are given.
use http://ip:8080/?action=snapshot or http://ip:8080/?action=stream or http://ip:8080/ for Webpage

Code: Select all

mjpg_streamer -i "/usr/lib/input_uvc.so -d /dev/video0 -y -r 640x480 -q 95 -f 4 -l auto" -o "/usr/lib/output_http.so -p 8080 -w /usr/local/www -c user:id"
Make it autorun

Code: Select all

sudo nano /etc/init.d/mjpg_streamkick
Add this inside the file just created (remark to tweak here the mjpeg paramaters

Code: Select all

#! /bin/sh
# /etc/init.d/mjpg_streamkick

# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting mjpg_streamkick script"
    export LD_LIBRARY_PATH=/usr/local/bin
    mjpg_streamer -i "/usr/lib/input_uvc.so -d /dev/video0 -y -r 640x480 -q 95 -f 4 -l auto" -o "/usr/lib/output_http.so -p 8080 -w /usr/local/www -c user:id" &
    ;;
  stop)
    echo "Stopping webcam script"
    killall mjpg-streamer
    ;;
  *)
    echo "Usage: /etc/init.d/mjpg_streamkick {start|stop}"
    exit 1
    ;;
esac

exit 0
Make it run

Code: Select all

sudo chmod 755 /etc/init.d/mjpg_streamkick
sudo update-rc.d mjpg_streamkick defaults
Clean Up

Code: Select all

cd /home/pi/
rm -rf mjpg-streamer
Use to Stop

Code: Select all

sudo /etc/init.d/mjpg_streamkick stop

jurmelius
Posts: 86
Joined: Sun Jul 22, 2012 7:00 pm

Re: How To Install Mjpg-Streamer

Thu Dec 19, 2013 1:45 pm

Small add... With this compiled version the format is always YUV (-y parameter). Isn't MJPEG better choise, havn't got one though... FPS is quite poor at VGA and CPU is hi. (75%)... so the webCam does not support Mjpeg?
How others are getting 720p with good fps?
How about timestamp burned into the image?

danjperron
Posts: 3391
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: How To Install Mjpg-Streamer

Fri Dec 20, 2013 3:53 am

Hi Jurmelius,

You made me worry that mjpeg-streamer is not working anymore with the new raspbian.

So I recompile it using a fresh SD card and it is ok.


This is my step by step method for mjpeg-streamer.

It is base from this link http://wolfpaulus.com/jounal/embedded/r ... pi_webcam/


1 - From a fresh debian

Code: Select all

sudo apt-get update
sudo apt-get upgrade
2 - I install avachi. The bonjour server. This way I could just enter the Rpi hostname , with the .local termination. No need to know the IP.

Code: Select all

sudo apt-get install libnss-mdns
if you want to change the raspberry name you will need to modify /etc/hosts and /etc/hostname with the new name but before run the application hostname to set it

I change raspberrypi to mypicam
sudo hostname mypicam
sudo nano /etc/hosts and change raspberrypi to mypicam
sudo nano /etc/hostname and change raspberrypi to mypicam
Now we are able to access our Rpi using mypicam.local instead of the IP.

3 - Needed Applications and libraries

Code: Select all

sudo apt-get install subversion
sudo apt-get install libjpeg8-dev
sudo apt-get install imagemagick
sudo apt-get install libv4l-0
sudo apt-get install libv4l-dev
sudo apt-get install uvcdynctrl

4 - Shutdown, power off, install webcam and power ON.

Code: Select all

sudo shutdown -h now
P.S. never shutdown by removing the power. You will corrupt the SD card.

Please install the camera at the top USB port if you have a model B. For some reason my webcam doesn’t work on the bottom one.

5 - Check the Camera


Is the camera is seen by the usb port

Code: Select all

lsusb

This is what I got
[email protected] /usr/local/bin $ lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 045e:0723 Microsoft Corp. LifeCam VX-7000 (UVC-compliant)
Bus 001 Device 005: ID 0bda:8172 Realtek Semiconductor Corp. RTL8191SU 802.11n WLAN Adapter
[email protected] /usr/local/bin $
Is the camera is mjpeg capable

Code: Select all

uvcdynctrl -f
And this is what I got
[email protected] /usr/local/bin $ uvcdynctrl -f
Listing available frame formats for device video0:
Pixel format: MJPG (MJPEG; MIME type: image/jpeg)
Frame size: 352x288
Frame rates: 30
Frame size: 1600x1200
Frame intervals: 2/15
Frame size: 1280x1024
Frame intervals: 2/15
Frame size: 1024x768
Frame intervals: 2/15
Frame size: 800x600
Frame rates: 30
Frame size: 640x480
Frame rates: 30
Frame size: 320x240
Frame rates: 30
Frame size: 176x144
Frame rates: 30
Frame size: 160x120
Frame rates: 30
[email protected] /usr/local/bin $
6 - Download, compile and install mjpeg-streamer

Code: Select all

cd ~
svn co https://svn.code.sf.net/p/mjpg-streamer/code/mjpg-streamer/ mjpg-streamer
cd mjpg-streamer
make USE_LIBV4L2=true clean all
sudo make install
7 - Create a script to run mjpeg-streamer

Code: Select all

sudo nano /usr/local/bin/streamer800x600.sh

Code: Select all

#!/bin/bash
killall mjpg_streamer
/usr/local/bin/mjpg_streamer -i "/usr/local/lib/input_uvc.so -n -f 30 -r 800x600" -o "/usr/local/lib/output_http.so -p 10088 -w /usr/local/www" &

Make the script executable

Code: Select all

sudo chmod +x /usr/local/bin/streamer800x600.sh
Try it

Code: Select all

streamer800x600.sh
Now we will open an other computer with any browser like safari,firefox or chrome. Don’t use internet explorer because it won’t work!

This will only work locally.
http://mypicam.local:10088

If you use something else than mypicam just change it or use the IP instead with the ":10088" of course


If you want the webcam to run at startup, simply add in /etc/rc.local the following line just before the ¨exit 0¨ line.

Code: Select all

. /usr/local/bin/streamer800x600.sh


P.S. don’t forget the dot.

Daniel 

danjperron
Posts: 3391
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: How To Install Mjpg-Streamer

Fri Dec 20, 2013 5:12 am

HI Jurmelius,

your compilation method is more or less the same than me.

You are making some unnecessary step since by default the mjpeg_streamer will install itself to /usr/local/bin. No need to specify a destination and copy it after.

I don't think that you will be able to get 30FPS at 720p. My little Rpi robot which use a c-260 run around 12fps at 720p. And if my macbook use the same wifi channel, it is reduce at 9fps. Ethernet bandwidth is also a big factor there. There is no noticeable difference between 100mbs ethernet and wifi 'N'. But between wifi 'g' and 'n' there is a big one. Increasing the cpu clock doesn't change the frame rate much.

Also light illumination is a big factor. I think this is all to do with the automatic integration time of the web cam.

Daniel

danjperron
Posts: 3391
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: How To Install Mjpg-Streamer

Fri Dec 20, 2013 5:27 am

If I use VLC instead of a web page, the frame rate is way higher but VLC don't tell the frame rate.

Maybe 30fps is possible.

Yep the javascript web page doesn't display real maximum frame rate.


B.T.M The c-260 doesn't display nice with VLC but the C-920 and the VX-7000 from microsoft are ok.
Daniel

jurmelius
Posts: 86
Joined: Sun Jul 22, 2012 7:00 pm

Re: How To Install Mjpg-Streamer

Fri Dec 20, 2013 1:24 pm

Great posts.. But, how about the timestamp burn on the image?

danjperron
Posts: 3391
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: How To Install Mjpg-Streamer

Fri Dec 20, 2013 7:06 pm

Hi Jurmelius,

I check the mjpg_streamer and the text overlay is not build-in.


Then to minimize the process on the RPI, you could include the text overlay using css at the web page.

This is a modified stream_simple.html web page with a text overlay.

Obviously you could make your own javascript to include date and any text relevant to your application.

A modified /usr/local/www/stream_simple.html webpage

Code: Select all

<html>
  <head>
    <title>MJPG-Streamer - Stream Example</title>
<style>
.container { position:relative; }
.container video {
    position:relative;
    z-index:0;
}

.overlay {
    position:absolute;
    top:0;
    left:0;
    z-index:1;
}
</style>
  </head>
  <body>
    <div class="container">
        <img src="/?action=stream"/>
    <div class="overlay">
        <p>&nbsp;&nbsp;Type your text there</p>
    </div>
</div>
  </body>
</html>

Daniel

danjperron
Posts: 3391
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: How To Install Mjpg-Streamer

Fri Dec 20, 2013 8:23 pm

And this is with the time stamp

/usr/local/www/stream_simple.html

Code: Select all

<html>
  <head>
    <title>MJPG-Streamer - Stream Example</title>
<style>
.container { position:relative; }
.container video {
    position:relative;
    z-index:0;
}

.overlay {
    position:absolute;
    top:0;
    left:0;
    z-index:1;
}
</style>
  </head>
  <body>
    <div class="container">
        <img src="/?action=stream"/>
    <div class="overlay">
     <div style="position:absolute;width:800px;font-size:200%;font-weight:bold; background-color:lightgray; filter:alpha(opacity=60); opacity:.6;" id="time_span"> </div>
    </div>
</div>


 <script type='text/javascript'>
timer();

function timer(){
 var now = new Date,
     hours = now.getHours(),
     ampm  = hours<=11 ? ' AM' : ' PM'
     minutes = now.getMinutes(),
     seconds = now.getSeconds(),
     t_str = "&nbsp;" + [hours-12,
              (minutes < 10 ? "0" + minutes : minutes),
              (seconds < 10 ? "0" + seconds : seconds)]
                 .join(':') + ampm + "&nbsp;&nbsp;&nbsp;&nbsp;Put Your text there";
 document.getElementById('time_span').innerHTML = t_str;
 setTimeout(timer,1000);
}

</script>

  </body>
</html>
Daniel

jurmelius
Posts: 86
Joined: Sun Jul 22, 2012 7:00 pm

Re: How To Install Mjpg-Streamer

Sun Dec 22, 2013 11:00 am

I Have Microsoft LifeCam HD 5000 and

Code: Select all

uvcdynctrl -f 
show a vast list of frame sizes of both

Code: Select all

Pixel format: YUYV (YUV 4:2:2 (YUYV); MIME type: video/x-raw-yuv)
and

Code: Select all

Pixel format: MJPG (MJPEG; MIME type: image/jpeg)
If I give quality parameter to input plugin e.g. "-q 90" output goes to YUV instead of MJPEG. With Mjpeg mode pi will give 1280x720 at 30 FPS almost fluently! (10MB output!)
I use [email protected] for 2.4Mb output (better for 2Mb WAN).

-n to input parameter will not load the controll mode.

Here is how to turn off the stupid autofocus of LifeCam
http://www.bot-thoughts.com/2013/01/lif ... berry.html

danjperron
Posts: 3391
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: How To Install Mjpg-Streamer

Sun Dec 22, 2013 4:40 pm

Yes the uvcdynctrl -c show all the controls.

-g will read it and -s will set it

On the C-920 I made the focus fix also.

First I set the auto focus off and I set the focus manually

Code: Select all

uvcdynctrl -s "Focus, Auto" 0
uvcdynctrl -s "Focus (absolute)" 100
Controls are different from each camera so you need to do -c to figure out which ones are available.

B.T.W. In mjpeg mode the mjpg_streamer just pass the puck. Its mean that it will just transfer the video signal with no decoding and encoding. This is why there is no text overlay or quality change possible and why it is so fast.

Daniel

jurmelius
Posts: 86
Joined: Sun Jul 22, 2012 7:00 pm

Re: How To Install Mjpg-Streamer

Sun Dec 22, 2013 7:25 pm

Has anyone managed to switch the webCam's LED off/on with -l on/off parameter to input plugin?
If the LED can be controlled by output plugin like (this is White Balance Temperature, Auto/off)

Code: Select all

http://raspiIP:port?action=command&dest=0&plugin=0&id=9963788&group=1&value=0
it will be quite easy to build relay system to the LED in order to controll real lightSource..

bilal
Posts: 1
Joined: Tue Mar 18, 2014 12:49 am

Re: How To Install Mjpg-Streamer

Tue Mar 18, 2014 12:54 am

Thank you my friend, I still search tooo much to solve this problem
All of another pages didn't illustrate steps carefully as you
Thank you very much

Tony-d
Posts: 54
Joined: Mon Jun 02, 2014 11:54 pm

Re: How To Install Mjpg-Streamer

Fri Jun 06, 2014 12:16 am

Hello, and thank you in advance for your help.
I am working on the cam rover project as outlined in magpie magazine. I am trying to install
mjpg-streamer
However, when I run the “make” command I get a fatal error: “videodev.h no such file no such directory. “ I have tried all the fixes that I have found as well as asked for help on the raspberry Pi home page and the source forge, Tom says he recalls the error. But not the fix, I have gone so fare as to down load a new O.S. run the updates and the upgrades and try the install and it still crashed with the same error at the same spot. I am thinking either I am doing something dumb or they have up graded there Software? I have also tried to install tried to install the mjpg-streamer_94-i386.deb but I can’t seem to get that to extract correctly. (grrrrrr) the link in the article points to the r63 file that dies on the “make’ command.
Thank you all very much.
Tony

demonmaestro
Posts: 21
Joined: Fri Jun 07, 2013 10:07 am

Re: How To Install Mjpg-Streamer

Fri Jun 06, 2014 12:20 am

Follow the exact instructions that I have posted on the first post and it will work. I give you line by line commands. Also what camera you using?

Tony-d
Posts: 54
Joined: Mon Jun 02, 2014 11:54 pm

Re: How To Install Mjpg-Streamer

Sun Jun 08, 2014 1:23 am

I have this working now, thank you all very much

Return to “Graphics, sound and multimedia”