Go Down

Topic: Guide to Setup Streaming Web Cam on the Yun (Read 82158 times) previous topic - next topic

PrinceDaniel

Sep 18, 2013, 04:25 pm Last Edit: Sep 18, 2013, 05:34 pm by MadScience Reason: 1
Hi All

Sharing my experience and tutorial below as it may be of use to some.

I thought I would try hooking up a web cam to my Yun and stream it over WiFi. Basically I am building a WiFi controlled robot and want to mount a camera which can be viewed over WiFi as well.

This is my experience:

The good:
- It does work once you get everything configured

The bad:
- Fairly tricky to set up if you don't know how
- The CPU offers little speed for encoding so you end up with a laggy video. I counted about 4 seconds lag. Also the speed gets incrementally worse as the encoding runs.
- No mjpg-streamer or gstreamer binary (unless  you want to custom compile - I dont :) ) so I used ffserver
- Could only get it working with flv/swf format and at low resolution
- Unless you want to tinker with your operating system a bit and move your installs to the SD card, you will use about 85% of your Yun's storage for the binaries and libraries

After this experiment, I would suggest avoiding trying to encode and stream live video over WiFi using the Yun. I think the processor is not up to this kind of task.
For this task, I have decided to use a separate security camera with inbuilt WiFi for video and run the Yun as my controller to issue commands to the robot over WiFi.

I would love to hear from anyone if they can get this running smoother.

Here are the instructions below if anyone is interested:

- Join your Yun to your WLAN
- SSH into OpenWRT via the IP or via arduino.local hostname
- Check your camera's compatibility (some are UVC, some are GSPCA, some not supported at all). I would suggest taking a look here: http://wiki.openwrt.org/doc/howto/usb.video
- Install either the UVC driver or GSPCA (if not already installed) e.g. opkg install kmod-video-uvc
- Plug your camera into usb slot (type dmesg to see if your camera is detected and drivers working correctly). I used a Microsoft LifeCam HD-3000
- install ffmpeg via opgk install ffmpeg
- install ffserver via opkg install ffserver
- install video4linux2 package via opkg install v4l2
- Install nano package so you can edit text (I like nano) - opkg install nano
- add your micro sd card (it should appear as /dev/sda1 by default)
- Create a folder /mnt/sda1 (mkdir /mnt/sda1)
- mount your sd card - mount /dev/sda1 /mnt/sda1
- Create an ffserver config file under /etc using nano (nano /etc/ffserver.conf). You may need to modify this file if your mount paths are different
- Enter and save the following config:
Code: [Select]

Port 8090
BindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 10
MaxBandwidth 50000
RTSPPort 9090
NoDaemon

<Feed videofeed.ffm>
File /mnt/sda1/videofeed.ffm
#You should match the above to your SD Card's mount point
FileMaxSize 10M
ACL allow 127.0.0.1
</Feed>

<Stream video.swf>
# coming from live feed 'videofeed'
#Format mjpeg
Feed videofeed.ffm
Format flv

AVOptionVideo flags +global_header
VideoCodec  flv
VideoBitRate 128
VideoBufferSize 2000
VideoFrameRate 4
VideoSize 320x240
VideoQMin 1
VideoQMax 3
ACL allow 192.168.0.0 192.168.255.255

NoAudio

</Stream>

ACL allow localhost


- Use CTRL + W to write your file
- run ffserver command in SSH (since we are not running in daemon mode, it will occupy the SSH session). If you get an error then check your config file. Don't close this SSH window yet
- Open a second ssh session and run the following command
Code: [Select]
ffmpeg -v verbose -r 5 -s 320x240 -f v4l2 -i /dev/video0 -c:v flv http://localhost:8090/videofeed.ffm

- Hopefully your session will start running without errors. If any errors, review your setup as per above
- Open your web browser to http://arduino.local:8090/video.swf
- Your video should start showing

Hopefully I haven't forgotten any steps above.
As I said, its not perfect but it does work. If anyone can improve on this or wants to cross compile mjpg-streamer then please let me know

Also on a side note, if anyone wants to see what binaries are available, you can view the list here:
http://download.linino.org/dogstick/all-in-one/latest/packages/

Cheers
Daniel

PrinceDaniel

#1
Sep 18, 2013, 05:26 pm Last Edit: Sep 18, 2013, 05:32 pm by MadScience Reason: 1
Sure will do when done :)

He is going to be the guardian of my apartment whilst I am out. Will have PIR motion detection should someone unwelcome enter and be accessible over the internet so I can take a poke around and see whats up.

federicofissore

very nice! congrats!!

and sorry for the lack of mjpg-streamer and gstreamer: we have their source code but they don't compile, that's why they are currently missing from the list. I hope we'll have them added soon

PrinceDaniel

Ah I see. Happy to help if I can.

If possible can you send me the steps you are taking to cross compile and ill see if I can get it working?
Are you using Ubuntu to compile?
What kind of error message is it throwing during compile? If its due to system dependencies then we may be out of luck for now.

fibasile

#4
Sep 19, 2013, 02:35 am Last Edit: Sep 19, 2013, 02:37 am by fibasile Reason: 1
I got the mjpg-streamer compiled on my local toolchain, you can find the package, and the dependencies here: https://www.dropbox.com/sh/6nv5f2datb3n2ps/nj-z27B6i1

To install them just copy them over the YUN and opkg install the complete filename(s).

It only works with an UVC webcam which I unfortunately don't have at hand. Hope it's useful.

The usage is described here: http://wiki.openwrt.org/doc/howto/webcam

PrinceDaniel


I got the mjpg-streamer compiled on my local toolchain, you can find the package, and the dependencies here: https://www.dropbox.com/sh/6nv5f2datb3n2ps/nj-z27B6i1

To install them just copy them over the YUN and opkg install the complete filename(s).

It only works with an UVC webcam which I unfortunately don't have at hand. Hope it's useful.

The usage is described here: http://wiki.openwrt.org/doc/howto/webcam


Nice one. Thanks for uploading. My webcam is UVC so I will give it a test later. I wonder how the performance will compare with ffmpeg and ffserver

PrinceDaniel


I got the mjpg-streamer compiled on my local toolchain, you can find the package, and the dependencies here: https://www.dropbox.com/sh/6nv5f2datb3n2ps/nj-z27B6i1

To install them just copy them over the YUN and opkg install the complete filename(s).

It only works with an UVC webcam which I unfortunately don't have at hand. Hope it's useful.

The usage is described here: http://wiki.openwrt.org/doc/howto/webcam


Tested and working a charm. Video streaming smoothly at 5fps 640x480 resolution.
Well done mate.

If anyone else is interested. I would suggest using this build of mjpg-streamer over ffmpeg and ffserver as the throughput is much faster.

Instructions are below. Credit to fibasile for the binary upload of mjpg-streamer:
Join your Yun to your WLAN
- SSH into OpenWRT via the IP or via arduino.local hostname
- Check your camera's compatibility (some are UVC, some are GSPCA, some not supported at all). I would suggest taking a look here: http://wiki.openwrt.org/doc/howto/usb.video. At this time only UVC driver camera's are supported
- Install either the UVC driver (if not already installed) e.g. opkg install kmod-video-uvc
- Plug your camera into usb slot (type dmesg to see if your camera is detected and drivers working correctly). I used a Microsoft LifeCam HD-3000
- add your micro sd card (it should appear as /dev/sda1 by default)
- Create a folder or mount point /mnt/sda1 (mkdir /mnt/sda1)
- mount your sd card - mount /dev/sda1 /mnt/sda1
- use wget to download the mjpg-streamer binary ( you cant use it with drop box as it redirects to https. This module is not installed by default). I have uploaded it here for convenience : http://www.custommobileapps.com.au/downloads/mjpg-streamer.ipk
- install the package (I installed it in my root folder ~) - opkg install mjpg-streamer.ipk
- View the config options here - http://wiki.openwrt.org/doc/howto/webcam. I just ran it with the following command
Code: [Select]
mjpg_streamer -i "input_uvc.so -d /dev/video0 -r 640x480" -o "output_http.so -p 8080 -w /mnt/share" (/mnt/share is my sd card). You can also set it to start upon boot
- Open your web browser to: http://arduino.local:8080/?action=stream for a stream or http://192.168.1.1:8080?action=snapshot for a single snappy
- Enjoy

fibasile

Great, happy you made it.

btw, wget doesn't come with ssl compiled, but curl does!

AllSystemGO

Great guide MadScience. Works like a charm. Not with my Playstation eye but I bought a HD 3000 and it works great.

Stephan_84

Thanks for this guide MadScience! This is working with a C170 Webcam from Logitech.

sonique



I got the mjpg-streamer compiled on my local toolchain, you can find the package, and the dependencies here: https://www.dropbox.com/sh/6nv5f2datb3n2ps/nj-z27B6i1

To install them just copy them over the YUN and opkg install the complete filename(s).

It only works with an UVC webcam which I unfortunately don't have at hand. Hope it's useful.

The usage is described here: http://wiki.openwrt.org/doc/howto/webcam


Tested and working a charm. Video streaming smoothly at 5fps 640x480 resolution.
Well done mate.

If anyone else is interested. I would suggest using this build of mjpg-streamer over ffmpeg and ffserver as the throughput is much faster.

Instructions are below. Credit to fibasile for the binary upload of mjpg-streamer:
Join your Yun to your WLAN
- SSH into OpenWRT via the IP or via arduino.local hostname
- Check your camera's compatibility (some are UVC, some are GSPCA, some not supported at all). I would suggest taking a look here: http://wiki.openwrt.org/doc/howto/usb.video. At this time only UVC driver camera's are supported
- Install either the UVC driver (if not already installed) e.g. opkg install kmod-video-uvc
- Plug your camera into usb slot (type dmesg to see if your camera is detected and drivers working correctly). I used a Microsoft LifeCam HD-3000
- add your micro sd card (it should appear as /dev/sda1 by default)
- Create a folder or mount point /mnt/sda1 (mkdir /mnt/sda1)
- mount your sd card - mount /dev/sda1 /mnt/sda1
- use wget to download the mjpg-streamer binary ( you cant use it with drop box as it redirects to https. This module is not installed by default). I have uploaded it here for convenience : http://www.custommobileapps.com.au/downloads/mjpg-streamer.ipk
- install the package (I installed it in my root folder ~) - opkg install mjpg-streamer.ipk
- View the config options here - http://wiki.openwrt.org/doc/howto/webcam. I just ran it with the following command
Code: [Select]
mjpg_streamer -i "input_uvc.so -d /dev/video0 -r 640x480" -o "output_http.so -p 8080 -w /mnt/share" (/mnt/share is my sd card). You can also set it to start upon boot
- Open your web browser to: http://arduino.local:8080/?action=stream for a stream or http://192.168.1.1:8080?action=snapshot for a single snappy
- Enjoy




Hi MadScience,

I followed your useful steps with YUN and my Cam USB 2.0 PC Camera (Sabrent WCM-6LNV) that is UVC compatible as you can see from http://www.ideasonboard.org/uvc/.
But when I try this command

Code: [Select]
mjpg_streamer -i "input_uvc.so -d /dev/video0 -r 640x480" -o "output_http.so -p 8080 -w /mnt/share

and I try to connect to http://arduino.local:8080/?action=stream nothing happens.

What could be the problem?

Thanks a lot.

muhkuh

try this:
Code: [Select]
mjpg_streamer -i "input_uvc.so" -o "output_http.so"

it will use the default values an your link should work.

if you use
Code: [Select]
mjpg_streamer -i "input_uvc.so" -o "output_http.so -p 8080 -w /www/webcam"

Code: [Select]
http://arduino.local:8080/webcam 
will give you the demo page of mjpg streamer.

muhkuh

by the way, any idea how to stream on a webpage that runs on the yun's webserver?
i can see the stream on the mjpg-streamer webserver, ut i cant embedd it on the Yun webserver.

ex: yun webserver runs on port 81
mjpg-streamer runs on port 8080

i can go to yun.local:8080 to see the index.html with the webcam stream, but the
Code: [Select]
$('#content').load('/arduino/temperature');
does not work.

i can go to yun.local:81 and on index.html the above code snippet works, but the webcam stream does not.

sonique

Hi guy,

when I try your command, I receive this

Quote
MJPG Streamer Version: svn rev: exported
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


:~

sonique

Hi guys,

some update.


With this command stream video work fine:

Code: [Select]
mjpg_streamer -i "input_uvc.so -y -n -f 30 -r 320x240" -o "output_http.so -p 8080 -n -w /www/webcam"

My web doesn't support MPEG stream, only YUV.

My cam support also 640X480@15 fps but stream is too slow. I tried also 640X480@5 but nothing. Some suggestion?

Tnx


Go Up