1 (edited by skcolb 2011-01-30 16:46:45)

Topic: Webcam Streaming with MJPG-streamer

Earlier today I was following billyzelsnack's info on capturing video from a webcam and drawing it to the Infocast framebuffer, which worked great for displaying the image on-screen. After I got that working, I started looking into how to stream webcam video, and I ran across the open-source MJPG-streamer.

It was relatively easy to set up Motion JPEG streaming from my Infocast 3.5" to my desktop's web browser (Firefox or Chrome work). I was able to do 1280x720 (the resolution of my Logitech C260 webcam) at 15 FPS just fine.

Here's roughly how I recall doing it (it's late). I didn't have to write a single line of code.

1) Download libjpeg (required by mjpg-streamer): http://www.ijg.org/files/jpegsrc.v8c.tar.gzp

2) Compile libjpeg on the Chumby/Infocast. I was able to do

./configure
make
make test

without any problems.

3) Install libjpeg. You can either remount the root filesystem as read/write and install to the default location with

make install

or follow the instructions in install.txt to install to a location of your choosing.

4) Download mjpg-streamer: http://sourceforge.net/projects/mjpg-st … z/download

5) Compile mjpg-streamer. If you didn't install libjpg to the default locations, you'll have to add the install location to the include and library search paths. You'll get a crap-ton of warnings, which I didn't look into.

6) Plug in your USB webcam. Hopefully it works with the built-in drivers.

6) Run mjpg_streamer. I had trouble setting the search path for it to find the input plugin, but what ultimately worked for me was:

./mjpg_streamer -i "./input_uvc.so -r 1280x720 -d /dev/video0 -f 15" -o "./output_http.so -w www"

7) The motion jpeg stream is now available on your browser at:

http://your-chumby-ip:8080/?action=stream

There seemed to be some performance issues when I got 3 people on the stream. Anyway, hope this is useful/fun for somebody.

Re: Webcam Streaming with MJPG-streamer

Oh neat wink

I was doing all this myself with a python script.  This is a... can't say its neater... but its a different solution smile

Thanks for this.

Re: Webcam Streaming with MJPG-streamer

Cool.

Does this encode the images on the Chumby? A couple weeks ago I got a camera that delivers data already JPEG encoded, but I've been distracted by other projects. I was hoping that it would allow for 640x480 or more at 30fps.

Re: Webcam Streaming with MJPG-streamer

billyzelsnack wrote:

Does this encode the images on the Chumby?

No, it's definitely getting a (M)JPEG compressed stream from the webcam. There's an option on the input plugin to get YUV formatted images from the webcam and to do compression on the Chumby. When enabled, CPU usage maxes out and performance goes way down.

I'm not sure where the framerate limitation comes from (CPU usage is about ~20% for one stream), whether it's the webcam or the network connection. At 640x480, I stop noticing a visible improvement around 25fps, and at 1280x720, around 20fps.

Re: Webcam Streaming with MJPG-streamer

Cool. Your method is much easier to implement than mine!

I don't understand what you mean by "stop noticing a visible improvement" Are you tweaking some sort of quality value that trades quality for fps?

Madox. Your python script can get this level of performance without compiling any thirdparty stuff?

Re: Webcam Streaming with MJPG-streamer

billyzelsnack wrote:

I don't understand what you mean by "stop noticing a visible improvement" Are you tweaking some sort of quality value that trades quality for fps?

There's an fps parameter for mjpg-streamer. I'm not sure where it is actually used, but putting in 5 gets me what looks like 5 fps, same with 10, all the way up to about 25 for 640x480, beyond which it all looks the same. Could be the same thing for 1280x720, my stroboscopic eye is not well-calibrated above 15 fps or so.

You can actually tweak quality if you're doing the compression on the Chumby, but you have to settle for a very low-res image and blocky compression in order to get any decent framerate.

7 (edited by happyshow 2011-02-02 09:33:34)

Re: Webcam Streaming with MJPG-streamer

Could this functionality be made into an app? I am very technically inclined but not sure if I can accomplish the steps you laid out being that I'm a Windoze user. Also, would streaming mpeg4 with audio work? I have a Linksys WVC80N IP camera, which supports mpeg4 video, motion jpeg, rtsp mobile streaming and would love to be able to see it on my Insignia Infocast/Chumby. Thanks.