Arduino Forum

Products => Arduino Yún => Topic started by: PrinceDaniel on Sep 18, 2013, 04:25 pm

Title: Guide to Setup Streaming Web Cam on the Yun
Post by: PrinceDaniel on Sep 18, 2013, 04:25 pm
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
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: PrinceDaniel on Sep 18, 2013, 05:26 pm
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.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: federicofissore on Sep 18, 2013, 10:16 pm
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
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: PrinceDaniel on Sep 19, 2013, 01:08 am
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.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: fibasile on Sep 19, 2013, 02:35 am
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
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: PrinceDaniel on Sep 19, 2013, 07:40 am

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
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: PrinceDaniel on Sep 19, 2013, 08:03 am

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
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: fibasile on Sep 19, 2013, 10:39 am
Great, happy you made it.

btw, wget doesn't come with ssl compiled, but curl does!
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: AllSystemGO on Nov 03, 2013, 04:21 am
Great guide MadScience. Works like a charm. Not with my Playstation eye but I bought a HD 3000 and it works great.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: Stephan_84 on Nov 06, 2013, 08:47 pm
Thanks for this guide MadScience! This is working with a C170 Webcam from Logitech.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: sonique on Nov 07, 2013, 09:37 am


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/ (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.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: muhkuh on Nov 07, 2013, 07:01 pm
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.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: muhkuh on Nov 07, 2013, 07:45 pm
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.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: sonique on Nov 07, 2013, 08:36 pm
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


:~
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: sonique on Nov 08, 2013, 12:48 am
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

Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: muhkuh on Nov 08, 2013, 11:23 am
Hi,

i use a microsoft lifecam 3000 and the yun can stream 1280*720 @ 15fps without problems over wifi.
over internet i am limited by my 5Mbit upload speed to less (960*580 @ 5fps is doable) but it works.
Watching my fishtank at work :D

Greetings
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: sonique on Nov 08, 2013, 02:57 pm
Thanks muh,

At this point, I believe is a WebCam problem.

Can you use your lifecam whit arduino-YUN at 960*580 @ 5fps ?

TNX


Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: muhkuh on Nov 08, 2013, 06:22 pm
yes, it will crop out whatever resolution you set with the
Code: [Select]
-r ###x### parameter.
Aslong as its smaller then what the webcam can supply.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: AllSystemGO on Nov 08, 2013, 10:17 pm
Hey muhkuh,

   I currently have a microsoft 3000 too and I was wondering in what browser are you streaming? Cause for me IE downloads the stream same as chrome and FF streams it the right way but the browser crashes at some point. If I try it on a Android tablet I have the same problem. Can you help me.

Thanks
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: muhkuh on Nov 09, 2013, 01:53 pm
Hi,

for me it works fine in FF and Chrome. not in IE 10.
but if you look in your www/webcam folder, there are some different ways of getting an image (jquery examples...)

easiest if you put
Code: [Select]
-w /www/webcam
as output parameter, and then you get the demo page for mjpg-streamer which shows all the different possibilities if you browse to your yun on port 8080.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: AllSystemGO on Nov 17, 2013, 03:25 am
Ok I saw what you were saying muh and it helped me with my project thank you. One last think where do you have the information of what parameters to pass and what they mean??? I'm trying to find info on that.

By the way is there a easy way to save a snapshot, programmatically, on the YUN SD ? Cause if I go http://yunip:8080/?action=snapshot it takes a snapshot in my browser but it's not saved on my SD card.

Thank you again
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: lucad79 on Nov 17, 2013, 10:24 am
Hi

for capturing a single image, I suggest the use of fswebcam:
http://www.lucadentella.it/2013/11/15/yun-colleghiamo-una-webcam-1/
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: ProfePaco on Nov 23, 2013, 02:33 pm
Hi there:

Can anybody recommend me a webcam, with infrared leds, suitable for streaming with Arduino yun in the darkness?

Thanks
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: cristiansaavedra on Nov 30, 2013, 04:36 pm
Hi a couple of things:

1.  The comand opkg has a mistake in ffmpeg. If copy and paste give an error:
It is easy to know the error but please correct in the first post.

root@Arduino:/mnt/sda1# opgk install ffmpeg
-ash: opgk: not found

2. I dont know if I have a new version but the v4l2 package is not anymore:

root@Arduino:/mnt/sda1# opkg install v4l2
Unknown package 'v4l2'.
Collected errors:
* opkg_install_cmd: Cannot install package v4l2.
root@Arduino:/mnt/sda1#

I found in http://download.linino.org/dogstick/all-in-one/latest/packages/ this two similar libraries: libv4l_0.8.6-2_ar71xx.ipk and v4l-utils_0.8.6-2_ar71xx.ipk. Are They the same?

Thanks for the post and help
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: thomas-c on Dec 01, 2013, 12:03 am
Thank you for everyone's work on this subject!
Has anyone attempted to use a web cam that has built-in hardware encoding in order to reduce the workload on the AR9331?  I also wonder if H.264 compression would allow for better results for any given Internet upload bandwidth constraints, as compared to MJPEG.  Unfortunately my new Yun is still under the Christmas tree.

This is the info I have come across so far, for utilizing hardware-based H.264 compression:
http://www.logitech.com/en-us/product/hd-pro-webcam-c920
http://www.oz9aec.net/index.php/gstreamer/473-using-the-logitech-c920-webcam-with-gstreamer
http://kakaroto.homelinux.net/2012/09/uvc-h264-encoding-cameras-support-in-gstreamer/
http://wiki.matthiasbock.net/index.php/Logitech_C920,_streaming_H.264

As a side note, I don't know if the problem mentioned in the comments section for the 2nd url above has been sorted out, regarding the Logitech C920's variable frame rate issue in low light conditions.  In the same comments section, "Ricky" mentions the good results he achieved for his robot car project (I realize his board may have been a 1 GHz ARM as compared to the AR9331's 400 MHz MIPS, but still).  Cheers.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: cristiansaavedra on Dec 01, 2013, 12:42 am
Thanks,  with the mjpg_streamer is working well. I have a Logitech HD Webcam C310.

The http://192.168.0.4:8080/?action=stream is only working on Firefox browser by now.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: thomas-c on Dec 01, 2013, 03:23 am
In the future, would it be better for me to create a separate topic regarding hardware-based encoding/streaming attempts or continue to post info in this topic?  Thank you.

The previous urls I mentioned culminated into this interesting project/writeup - full credits to Alexandru Csete:
http://www.oz9aec.net/index.php/beaglebone/476-turning-the-beaglebone-into-a-high-definition-ip-camera

In the above page's comments section "Joris Pragt" describes his attempt to use a TP-Link router running OpenWrt but he ran into problems due to the router only having 32 MB RAM.  Here's hoping the Yun's 64 MB is sufficient to allow for 1920x1080 @ 30 fps.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: noblepepper on Dec 01, 2013, 02:48 pm
I haven't seen any discussion of using the H.264 protocol in the forum, once you unwrap your Yun and start to play with it a new thread about H.264 would probably be a good idea. If you get it working yourself someone else would appreciate your experience, if not someone will probably help.

While I used info from this thread to get my webcam going, it is getting long with separate discussions going on and it can be hard to pick out the parts that apply. When to start a new discussion is not an easy decision but if what you ask is answered in another someone will usually post a link to the answer.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: nounjog on Dec 03, 2013, 03:05 am

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,
first of all thank you very much for your explanation, it worked very well, with the same camera as you.
But i don't  really understand what utility of the sd card? Is it something like a temporary memory in order to store a little bit of the stream ?

Thanks in advance !
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: federicofissore on Dec 04, 2013, 08:59 am

1.  The comand opkg has a mistake in ffmpeg. If copy and paste give an error:
It is easy to know the error but please correct in the first post.

root@Arduino:/mnt/sda1# opgk install ffmpeg
-ash: opgk: not found

You have written "opgk" instead of "opkg" and the error message is expected
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: Vadorequest on Dec 11, 2013, 12:25 pm
Hi, I would like to know if there is a way to start the stream from the Arduino program, because by now I have to manually connect using SSH and enter the following command line:
Code: [Select]
mjpg_streamer -i "input_uvc.so -d /dev/video0 -r 640x480" -o "output_http.so -p 8080 -w /mnt/share"

I would like to execute this command line from the Arduino, or from my Android application, there is a way?
Thank you.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: Vadorequest on Dec 11, 2013, 03:33 pm
I did it using this library:
jsch-0.1.50.jar

http://www.jcraft.com/jsch/
http://epaul.github.io/jsch-documentation/simple.javadoc/

Source code:
Code: [Select]

package com.iha.wcc.job.ssh;

import android.content.Context;
import android.os.AsyncTask;
import android.widget.Toast;
import com.jcraft.jsch.*;
import java.util.Properties;

/**
* Run a SSH command using Jsch library.
*/
public class SshTask extends AsyncTask<String, Integer, Boolean> {
    private static Session session;
    private static Channel channel;

    private Context context;
    private String host;
    private String user;
    private String password;
    private String command;

    /**
     * Constructor that load the necessary information to connect using SSG protocol.
     * @param context   Activity context, useful to display message.
     * @param host      Host IP to reach.
     * @param user      SSH user name.
     * @param password  SSH user password.
     * @param command   SSH command to execute.
     */
    public SshTask(Context context, String host, String user, String password, String command){
        this.context = context;
        this.host = host;
        this.user = user;
        this.password = password;
        this.command = command;
    }

    /**
     *
     * @param arg0
     * @return
     */
    @Override
    protected Boolean doInBackground(String... arg0) {
        JSch jsch=new JSch();

        Properties config = new Properties();
        config.put("StrictHostKeyChecking", "no");

        Session session;
        try {
            session = jsch.getSession(user, host, 22);
            session.setConfig(config);
            session.setPassword(password);
            session.connect();

            ChannelExec channel = (ChannelExec)session.openChannel("exec");
            channel.setCommand(command);
            channel.connect();

            SshTask.session = session;
            SshTask.channel = channel;

            return true;
        } catch (JSchException e) {
            e.printStackTrace();
            return false;
        }
    }

    @Override
    protected void onPostExecute(Boolean success){
        if(success){
            Toast.makeText(this.context, "Video stream successfully started.", Toast.LENGTH_SHORT).show();
        }else{
            Toast.makeText(this.context, "Unable to start the camera video stream.", Toast.LENGTH_LONG).show();;
        }
    }

    /**
     * Shutdown the camera video stream.
     */
    public static void disconnect(){
        if(SshTask.session != null){
            SshTask.channel.disconnect();
            SshTask.session.disconnect();
        }
    }

}
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: sonnyyu on Dec 11, 2013, 06:06 pm
opkg update
opkg install nano

nano /etc/config/mjpg-streamer

Code: [Select]

config mjpg-streamer core
option enabled "1"
option device "/dev/video0"
option resolution "640x480"
option fps "30"
option www "/www/webcam"
option port "8080"


/etc/init.d/mjpg-streamer enable
/etc/init.d/mjpg-streamer stop
/etc/init.d/mjpg-streamer start

access video from http://arduino.local:8080

Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: federicofissore on Dec 13, 2013, 01:49 pm
The init.d way is nice :)

BTW Vadorequest, can't you do that with runShellCommand?
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: ProfePaco on Dec 18, 2013, 10:40 am
And what about the audio?

Many cams have mic. So, can we streaming the audio at the same time?

Francisco
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: Vadorequest on Dec 18, 2013, 10:43 am
Good question, I didn't try to do that. Should be possible.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: ProfePaco on Dec 18, 2013, 10:46 am

Good question, I didn't try to do that. Should be possible.


when you have a IP web Cam. It is possible. I had one.

However, I think that the audio only worked with one browser, MS explorer, I think... not sure.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: ProfePaco on Dec 25, 2013, 12:54 am
I have been using Microsoft HD-3000 webcam with success.

Now I want to use another UVC webcam. However, it does not work.

Must I do something different if I want to use another cam? Should I indicate to the driver that the new cam has to be used now?

BTW, no ideas on audio streaming?

Merry Christmas,

Francisco
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: demolishun on Mar 26, 2014, 02:25 am
I have the streaming setup to my Yun and can view in browser. 

So how do I get this stream to a website streaming service?

I have searched around and cannot make heads or tails on how to do this.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: sonnyyu on Mar 26, 2014, 03:59 am

...
So how do I get this stream to a website streaming service?
...


What do you mean?
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: roadfun on Apr 25, 2014, 03:36 pm
I think he was asking how he could view the stream remotely, when not on the local network. Poking a hole through the firewall and mapping to the Yun would be one answer, I suppose. But I have not yet tried it myself.

Has anyone had problems with mjpg_streamer crashing after running for awhile? If so, do you know how to prevent this?
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: sonnyyu on Apr 25, 2014, 05:21 pm
Use top and free to monitor memory and cpu usage.

if high then change

Code: [Select]
option fps "30"

to

Code: [Select]
option fps "15"
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: roadfun on May 03, 2014, 05:34 pm
I have mjpg_streamer working ok with my Yun and camera but I'm interested in customizing it for my video monitoring project. I have searched and haven't found instructions for how to do something like this on the Yun (i.e. build the package after customizing the source). Any pointers would be appreciated. The hacks I have in mind would likely be useful to others.

Alternately or in addition I'm thinking of some hacks to fswebcam that should be useful for monitoring too.

Cheers.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: sonnyyu on May 06, 2014, 06:42 pm
Video application is very CPU-Intensive, Yun CPU might be suffer for speed . if high resolution and high fps is needed by use high speed CPU board or router.

http://forum.arduino.cc/index.php?topic=187766.msg1711221#msg1711221 (http://forum.arduino.cc/index.php?topic=187766.msg1711221#msg1711221)

Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: roadfun on May 06, 2014, 07:05 pm
I understand the CPU limitations but that's not the issue I'm trying to address. E.g. mjpg_streamer takes forever to take a first photo when you have it writing to a file. fswebcam does it very quickly. So it is an issues with the mjpg_streamer could I believe.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: sonnyyu on May 06, 2014, 07:36 pm
Quote
if high resolution and high fps is needed by use high speed CPU board or router.


high resolution could be  >= 4K
high fps could be >=60 fps

Some time high speed CPU is not even enough. We need GPU ( Graphics processing unit) and Multi-core one.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: roadfun on May 06, 2014, 07:42 pm
I guess I'm not explaining it well. I am not concerned with the frame rate, that's fine.

When I start fswebcam it can take a first picture very quickly. However when I start mjpg_streamer it takes it up to 8 seconds to capture an initial image (using the output_file.so module). I'd like to optimize the time to capture the first image in mjpg_streamer.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: sonnyyu on May 06, 2014, 08:13 pm
My video knowledge is rusty - almost 20 years old. I will try my best.  The mjpg_streamer use M-JPEG under hook.

M-JPEG is an intraframe-only compression scheme (compared with the more computationally intensive technique of interframe prediction). Whereas modern interframe video formats, such as MPEG1, MPEG2 and H.264/MPEG-4 AVC, achieve real-world compression-ratios of 1:50 or better, M-JPEG's lack of interframe prediction limits its efficiency to 1:20 or lower. But since it is an intraframe-only compression scheme the capture frame become very easy.

Plan A. drop  a  line to  mjpg_streamer team.

Plan B. test more robust ffmpeg-server which also provides M-JPEG streaming support.


Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: vanillaCoke on May 16, 2014, 06:37 am
Hi everyone

I have following this guide and have  some problem with install the video4linux2

I try the command: opkg install v4l2
and this is what I get:
"""""
Unknown package 'v4l2'.
Collected errors:
* opkg_install_cmd: Cannot install package v4l2.
root@arduino:~#
"""""

Please tell me where to get the package  smiley-cry

My computer science class group is working on an Arduino project
and hope that it can stream video

Thanks in advance smiley
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: PrinceDaniel on May 16, 2014, 09:02 am
Wow so many replies here since I started this thread some time back.
Apologies I have not replied to anyone, literally flat out with work here so I haven't actually checked this threat much since then. Actually I am still building my robot slowly... It now also had a Wi-Fi operated claw to pick up/move objects remotely and a self charge mechanism. Will post some pics/movie when I get a chance to finish it one day.

A PM from someone prompted me to check this thread, I hope everyone was able to rectify their issues and have their questions answered.

If the instructions are followed correctly from the first page, you should have no issues.
If not then please factory reset your unit and start again. Note I only tested this with a particular camera (HD-3000). Some cameras may use different drivers which may require additional or different steps to set it up.

Please note, there is a continuation of my original guide (1st post of this thread) on the 8th post of the first page for faster streaming using mjpg-streamer. Please take note of that as well.

Also there may be an easier way of setting this up now since the Yun has been out for some time. Not sure as I haven't tinkered with it for some time..

Also this may be of use to some:
http://www.lucadentella.it/en/2013/11/15/yun-colleghiamo-una-webcam-1/

Best of luck with it
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: sonnyyu on May 16, 2014, 01:44 pm

And what about the audio?

Many cams have mic. So, can we streaming the audio at the same time?

Francisco


The heart of Yun AR9331 does have I2S (Inter-IC Sound, Integrated Interchip Sound) bus build in. However Yun mask it among all other 29 GPIO pins.

Answer is No.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: rathodmanoj on Jun 17, 2014, 09:47 am
I am facing the same problem as vanillaCoke...

I am unable to install 'v4l2' package. It seems it is missing...

Is it renamed to a new package? Can anyone suggest any alternative package?

I have come to a complete stop in testing my web camera. Any help would be highly appreciated.

Thanks,
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: federicofissore on Jun 17, 2014, 09:55 am
Have you tried the guide linked by MadScience?
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: rathodmanoj on Jun 17, 2014, 02:11 pm
Hi Federico,
I installed kmod-video-uvc, ffmpeg and ffserver without any problems.

However when I try using following command
opkg install v4l2

I get following error message:
Quote

Unknown package 'v4l2'.
Collected errors:
* opkg_install_cmd: Cannot install package v4l2.


Also I found following packages in the libraries (link by madscience):
v4l-utils_0.8.6-2_ar71xx.ipk
libv4l_0.8.6-2_ar71xx.ipk

However, when I try to install, I get error message that the package index is corrupted:
Quote
Installing v4l-utils (0.8.6-2) to root...
Collected errors:
* opkg_install_pkg: Package v4l-utils md5sum mismatch. Either the opkg or the package index are corrupt. Try 'opkg update'.
* opkg_install_cmd: Cannot install package v4l-utils.


I can run successfully 'opkg update' and hence assuming that the packages are corrupted.

Am I referring to wrong libraries?

Please help!

Regards,
Manoj Rathod.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: federicofissore on Jun 17, 2014, 11:03 pm
I must ask you to try again, redoing a opkg update. Today we updated the package list: maybe you've tried during the update (it should be blazing fast but it sadly takes a couple of minutes anyway)
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: rathodmanoj on Jun 18, 2014, 06:51 am
Hi Federico,
I tried again. OPKG update works fine. Although I am unable to installed the v4l2 libraries. Here are the console logs:
Quote

root@Arduino:~#
root@Arduino:~#
root@Arduino:~# opkg update
Downloading http://downloads.arduino.cc/openwrtyun/1/packages/Packages.gz.
Updated list of available packages in /var/opkg-lists/attitude_adjustment.
Downloading http://downloads.arduino.cc/openwrtyun/1/packages/Packages.sig.
Signature check passed.
root@Arduino:~#
root@Arduino:~#
root@Arduino:~# opkg list v4l2
root@Arduino:~# opkg install http://download.linino.org/dogstick/all-in-one/latest/packages/libv4l_0.8.6-2_ar71xx.ipk
Downloading http://download.linino.org/dogstick/all-in-one/latest/packages/libv4l_0.8.6-2_ar71xx.ipk.
Installing libv4l (0.8.6-2) to root...
Collected errors:
* opkg_install_pkg: Package libv4l md5sum mismatch. Either the opkg or the package index are corrupt. Try 'opkg update'.
* opkg_install_cmd: Cannot install package libv4l.
root@Arduino:~# opkg install http://download.linino.org/dogstick/all-in-one/latest/packages/v4l-utils_0.8.6-2_ar71xx.ipk
Downloading http://download.linino.org/dogstick/all-in-one/latest/packages/v4l-utils_0.8.6-2_ar71xx.ipk.
Installing v4l-utils (0.8.6-2) to root...
Collected errors:
* opkg_install_pkg: Package v4l-utils md5sum mismatch. Either the opkg or the package index are corrupt. Try 'opkg update'.
* opkg_install_cmd: Cannot install package v4l-utils.
root@Arduino:~#


I did not find the v4l2 library for video4linux2. Hence tried installing v4l-utils and libv4l (I read somewhere that libv4l contains libv4l2).

I am not sure whether I am installing the right libraries. Are the libraries correct? Also, I will appreciate if you could advice if there are any steps that I am missing or doing incorrectly.

Best Regards,
Manoj Rathod.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: federicofissore on Jun 18, 2014, 09:29 am
Why are you manually installing files from download.linino.org?
Didn't
Code: [Select]
opkg install libv4l v4l-utils just work?
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: rathodmanoj on Jun 18, 2014, 01:14 pm
Hi Federico,
Many Thanks for your help and advice. I was able to download the v4l2 libraries successfully.

I am still struggling with the setup, but thought I will let you know that installation went successful.

Best Regards,
Manoj Rathod.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: federicofissore on Jun 18, 2014, 05:22 pm
Rock on! 8)
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: bolatu on Jul 04, 2014, 03:05 am
Hi guys,

I have a problem about taking picture from my Logitech HD Webcam C270. I have installed everything properly. However, I have this error when I want to take a picture:

Code: [Select]
root@Arduino:~# cd /mnt/sda1
root@Arduino:/mnt/sda1# fswebcam test.png
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
No input was specified, using the first.
Adjusting resolution from 384x288 to 352x288.
--- Capturing frame...
VIDIOC_DQBUF: No such device
No frames captured.
root@Arduino:/mnt/sda1#
root@Arduino:/mnt/sda1# cd
root@Arduino:~# fswebcam --no-banner --save photo.jpg
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
No input was specified, using the first.
Unable to find a compatible palette format.
root@Arduino:~# fswebcam --no-banner --save photo.jpg
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
No input was specified, using the first.
Unable to find a compatible palette format.


I have checked my systemlog and it didnt recognize my webcam:

Code: [Select]
Jul  4 00:56:16 Arduino kern.info kernel: [ 1211.550000] uvcvideo: Found UVC 1.00 device <unnamed> (046d:0825)
Jul  4 00:56:16 Arduino kern.info kernel: [ 1211.650000] input: UVC Camera (046d:0825) as /devices/platform/ehci-platform/usb1/1-1/1-1.1/1-1.1:1.0/input/input131
Jul  4 00:56:25 Arduino kern.info kernel: [ 1220.940000] usb 1-1.1: USB disconnect, device number 25
Jul  4 00:56:25 Arduino kern.info kernel: [ 1221.190000] usb 1-1.1: new high-speed USB device number 26 using ehci-platform
Jul  4 00:56:25 Arduino kern.info kernel: [ 1221.530000] usb 1-1.1: New USB device found, idVendor=046d, idProduct=0825
Jul  4 00:56:25 Arduino kern.info kernel: [ 1221.530000] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=2
Jul  4 00:56:25 Arduino kern.info kernel: [ 1221.540000] usb 1-1.1: SerialNumber: F4C44090
Jul  4 00:56:26 Arduino kern.info kernel: [ 1221.550000] uvcvideo: Found UVC 1.00 device <unnamed> (046d:0825)
Jul  4 00:56:26 Arduino kern.info kernel: [ 1221.650000] input: UVC Camera (046d:0825) as /devices/platform/ehci-platform/usb1/1-1/1-1.1/1-1.1:1.0/input/input132
Jul  4 00:56:30 Arduino kern.info kernel: [ 1225.550000] usb 1-1.1: USB disconnect, device number 26

Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: muhkuh on Aug 17, 2014, 02:39 pm
After updating my Yun to the latest version (1.41) and reinstalling mjpeg streamer,
i get a lot of image tearing in my stream.

anyone else expirienced these issues?
with the stock Yun firmware i had no issues at all, it worked perfectly.
But after update its realy bad. Kinda makes the webcam stream useless because the image is constanlty flashing in strange colors or showing half images.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: marco26 on Sep 20, 2014, 09:00 pm
I am having the exact same problem here with 1.4.2 and other updates. Does anyone know how I can return to the factory (1.0) firmware? I tried pressing the WLAN RST button for more than 30 seconds but it didn't help... Thanks!
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: stefanos90 on Sep 29, 2014, 03:49 pm
Hello,
I have website on a remote server,
does anyone have any idea how to pass the stream  http://arduino.local:8080/?action=stream  to the server?

I had an idea of iframe but still the video is streaming on arduino not on my server.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: mart256 on Dec 19, 2014, 12:49 pm
First I want to thank OP, Vadorequest and the guy who compiled the MJPEG streamer for Yun. I've been able to stream with my Microsoft Life HD 3000 with yun and using firefox as browser.

After updating my Yun to the latest version (1.41) and reinstalling mjpeg streamer,
i get a lot of image tearing in my stream.

anyone else expirienced these issues?
with the stock Yun firmware i had no issues at all, it worked perfectly.
But after update its realy bad. Kinda makes the webcam stream useless because the image is constanlty flashing in strange colors or showing half images.
I have yun with OpenWRT-Yun 1.0 (never upgraded, but doesn't have Linino I'm sure about that)
I downloaded the last version of mjpeg and I've this same problem, image tearing and strange color each 5-10 sec, not permanent though.
I noticed that the problem was reduced the lower the resolution is, I used 320x240 5 fps and the tearing was almost gone. Anyway, if it is a wifi problem I can't do much  :smiley-sweat:
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: sonnyyu on Dec 19, 2014, 03:56 pm
Stream high resolution video:

1. Cpu utilization
use command "top" to comfirm
http://forum.arduino.cc/index.php?topic=188690.msg1711487#msg1711487 (http://forum.arduino.cc/index.php?topic=188690.msg1711487#msg1711487)
offload compression to GPU, multiple core GPUs even better.

2. Memory usage
use command "free" to comfirm
expand the RAM.

3. Network bandwidth requirement
http://forum.arduino.cc/index.php?topic=188690.msg1711526#msg1711526 (http://forum.arduino.cc/index.php?topic=188690.msg1711526#msg1711526)
H.264/MPEG-4 has compression-ratios of 1:50
M-JPEG has compression-ratios of 1:20
by use H.264/MPEG-4 will reduce bandwidth requirement by 250%.

If you need stream 3D Blu-ray all of above have to address.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: sonnyyu on Dec 19, 2014, 04:06 pm
Plan B:

Offload all the heavy lift to Webcam which has H.264 built in

Logitech H.264 Webcam Technology

http://www.logitech.com/en-us/webcam-communications/articles/11612 (http://www.logitech.com/en-us/webcam-communications/articles/11612)

Title: Security options for the streaming video?
Post by: trippingly on Jan 31, 2015, 04:16 am
Thank you to the OP and the other contributors to this thread and project  :)  - I've been able to get the webcam stream up and have tinkered with starting and stopping the stream various ways (via a shell script, a php call to the script, a spacebrew button). It's very encouraging and points to some interesting projects to try.

I'm wondering what options there might be for making the stream secure. The password to mjpg_streamer (with the -c option) is sent in plain text, and it hasn't worked for me to access the stream via https. Looking on the web seems to indicate https is not how things are done with streaming, anyhow.

Is a non-linked, non-obvious page for the stream, linked to from another https page that uses basic authentication the simplest way to have some modest security?

- Doug
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: sonnyyu on Jan 31, 2015, 07:09 am
Plan A:

Turn on firewall of Yun, use IP authentication only allow authorized IP address ( Machine )  to access.



Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: trippingly on Jan 31, 2015, 09:52 pm
Thanks for the idea of the firewall, @sonnyyu - I hadn't thought of that.

Can I set the Yun's firewall via Luci to allow an outside web browser on a phone (the IP address will change, but the phone's MAC address is fixed and known) to connect to port 8080 on the Yun while blocking other MAC addresses?

I tried setting up a port forward for the phone's MAC address, but I am doing something incorrectly:

on Luci: Network > Firewall > Traffic Rules > Open ports on router with the settings:

Any TCP, UDP
From any host in any zone with source port 8765 and MAC xx:xx:xx:xx:xx:4A (MAC address I'm testing from)
To any host, port 8080 in any zone

(I'm new to the Yun's firewall and don't know anything yet about MAC addresses and the nuances of port forwarding - I am not even sure I have it turned on  ::) , though I tried iptables -L and got a lot of output.)

Thanks for ideas/guidance - this can go into a new thread if it would be better...

Doug
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: trippingly on Feb 01, 2015, 01:52 am
I'm making progress!

Instead of:

I tried setting up a port forward for the phone's MAC address, but I am doing something incorrectly:

on Luci: Network > Firewall > Traffic Rules > Open ports on router with the settings:

Any TCP, UDP
From any host in any zone with source port 8765 and MAC xx:xx:xx:xx:xx:4A (MAC address I'm testing from)
To any host, port 8080 in any zone
I tried on Luci: Network > Firewall > Port Forwards

IPv4-TCP
From any host in lan with source MAC xx:xx:xx:xx:xx:4A  (MAC address I'm testing from)
Via IP 10.0.1.8 at port 8765          (the Yun is at 10.0.1.8 )
any host, port 8080 in lan

This enabled the browser with the listed MAC to connect to the port 8080 stream via http://10.0.1.8:8765/stream.html

At this point, other browsers could still connect at http://10.0.1.8:8080, but when I added another rule (not sure if this is the best way to do this):

IPv4-TCP
From any host in lan
Via any router IP at port 8080
any host, port 8888 in lan      (8888 is just a random port I'm not using)

...then attempts to connect on 8080 fail as intended.

I'll see if I can now 1) set my home router (a Time Capsule, which can't handle this MAC filtering) to port forward 8080 to the Yun on 10.0.1.8, 2) put the MAC addresses of the devices I want to authorize into similar rules in the Yun firewall, and 3) modify the rules to work with connections coming from outside my home network.

Edit: Close, but no cigar...

The cable internet gateway puts its own MAC address on the traffic, so I won't be able to use the phone's MAC address this way. Back to the drawing board (on to the next drawing board)... :smiley-lol:
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: bobli on Apr 13, 2015, 08:27 am
Hello,
I have website on a remote server,
does anyone have any idea how to pass the stream  http://arduino.local:8080/?action=stream  to the server?

I had an idea of iframe but still the video is streaming on arduino not on my server.
Hello there,

Have any of you found a solution to this problem: inserting the webcam stream with its specific port in a random port 80 http page?

Cheers
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: jessemonroy650 on Apr 13, 2015, 10:51 pm
@bobli,
this question has been answer multiple times. Please start a new thread.

TIA
Jesse
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: bobli on Apr 14, 2015, 08:39 am
At the moment I have only found a way to display a custom web page I've created from Yun and how to display a webcam stream on a a web page with an adress like blablabla.local:8080

I still can't find a way to display the webcam stream on my custom webpage, I mean I don't need to have 2 adresses for my project.

Any help? 
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: sonnyyu on Apr 14, 2015, 01:00 pm
Sample html page from blablabla.local:8080:


Code: [Select]
<html>
  <head>
    <title>MJPG-Streamer - Stream Example</title>
  </head>
  <body>
    <center>
      <img src="/?action=stream" />
    </center>
  </body>
</html>


Code: [Select]
nano /www/video.html

Code: [Select]
<html>
  <head>
    <title>MJPG-Streamer - Stream Example</title>
  </head>
  <body>
    <center>
      <img src="http://192.168.0.102:8080/?action=stream" />
    </center>
  </body>
</html>


Use browser view video page at:

http://192.168.0.102/video.html (http://192.168.0.102/video.html)




Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: bobli on Apr 16, 2015, 10:30 am
It looks clear and simple, I look forward to testing it tonight!!!

I already had the sample page from mpg-streamer, I was just missing this part "<img src="http://192.168.0.102:8080/?action=stream" />" to put in my own page.... 

Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: Hasr on May 15, 2015, 03:26 pm
Is there a way to add a button on a webpage to start/stop the stream? Like a reset button... I want to send a command line to the yun via browser but I have no idea how to do it...
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: sonnyyu on May 15, 2015, 06:25 pm
Code: [Select]
nano /www/cgi-bin/mjpg-restart.cgi

Code: [Select]
#!/bin/ash
/etc/init.d/mjpg-streamer restart
echo "Content-type: text/html"
echo ""
echo "Restart..."
exit 0


Code: [Select]
chmod 755 /www/cgi-bin/mjpg-restart.cgi

http://arduino.local/cgi-bin/mjpg-restart.cgi (http://arduino.local/cgi-bin/mjpg-restart.cgi)

Code: [Select]
nano /www/webcam/stream.html

Code: [Select]
...
<form action="http://arduino.local/cgi-bin/mjpg-restart.cgi" method="get" target="_blank">
    <input type="submit" value="Restart">
</form>
...


http://arduino.local:8080/stream.html (http://arduino.local:8080/stream.html)

substitute start,stop  for restart if you needed.





Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: Hasr on May 18, 2015, 11:55 am
When I try to submit over the html page I get the following: "Access to this resource is forbidden"

EDIT: Forgot to "chmod 755 ..." I'ts working fine now. Thanks!

EDIT2: Is there a way to autoclose the new tab that opens with that form?
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: Hasr on May 18, 2015, 06:48 pm
Solved it with this :)

Code: [Select]
nano /www/webcam/stream.html

Code: [Select]

...
<form action="http://arduino/cgi-bin/mjpg-restart.cgi" method="get" target="_self">
    <input type="submit" value="Restart">
</form>
...


and

Code: [Select]
nano /www/cgi-bin/mjpg-restart.cgi

Code: [Select]
#!/bin/ash
echo "Content-type: text/html"
echo
echo "<html><head><meta http-equiv='refresh' content='0;URL=http://arduino:8081/index.html' /><title>Stream Restart</title></head><body><center><p>Restart in 10 seconds...</center></body></html>"

/etc/init.d/mjpg-streamer stop
sleep 10s; /etc/init.d/mjpg-streamer start
exit 0


Stops the stream for 10 seconds and redirects to the stream page after the stream "break"

I want this because I'm worried about overheating the Arduino Yun. Anyone having problem keeping the board running 24/7? I'm waiting for a Keyes L9110 Fan Module (http://i00.i.aliimg.com/wsphoto/v0/1756322846_2/Keyes-L9110-Fan-Module-for-Arduino-Robot-Design-and-Development-Control.jpg) to help cooling the precessor...
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: sonnyyu on May 20, 2015, 05:45 am
Solved it with this :)

Code: [Select]
nano /www/webcam/stream.html

Code: [Select]

...
<form action="http://arduino/cgi-bin/mjpg-restart.cgi" method="get" target="_self">
    <input type="submit" value="Restart">
</form>
...


and

Code: [Select]
nano /www/cgi-bin/mjpg-restart.cgi

Code: [Select]
#!/bin/ash
echo "Content-type: text/html"
echo
echo "<html><head><meta http-equiv='refresh' content='0;URL=http://arduino:8081/index.html' /><title>Stream Restart</title></head><body><center><p>Restart in 10 seconds...</center></body></html>"

/etc/init.d/mjpg-streamer stop
sleep 10s; /etc/init.d/mjpg-streamer start
exit 0


Stops the stream for 10 seconds and redirects to the stream page after the stream "break"
...
Great work.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: sonnyyu on May 20, 2015, 05:46 am
I want this because I'm worried about overheating the Arduino Yun. Anyone having problem keeping the board running 24/7? I'm waiting for a Keyes L9110 Fan Module (http://i00.i.aliimg.com/wsphoto/v0/1756322846_2/Keyes-L9110-Fan-Module-for-Arduino-Robot-Design-and-Development-Control.jpg) to help cooling the precessor...
http://forum.arduino.cc/index.php?topic=324160.0 (http://forum.arduino.cc/index.php?topic=324160.0)


Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: Opeth on Jan 17, 2016, 10:14 pm
Hello,

I have also managed to make my camera stream, but I stucked and I need an answer.
Every time I want to start the mjpg_streamer, I have to connect via SSH to start it, but I have an Android controlled car which is powered by a Power Bank and I don't know how to start the mjpg_streamer.
Is there any command I can write so that when I power the Arduino Yun the mjpg_streamer to start automatically, like in Windows start-up?

Thank you,
Waiting for your feedback.
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: sonnyyu on Jan 17, 2016, 10:33 pm
https://forum.arduino.cc/index.php?topic=188690.msg1503132#msg1503132 (https://forum.arduino.cc/index.php?topic=188690.msg1503132#msg1503132)




Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: tedzzzzzz on Sep 15, 2016, 07:09 pm
hi Guys! i hope someone is still active to help me :'(

i'm really having trouble with my camera not taking pictures. i tried everything but still nothing


--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
No input was specified, using the first.
Adjusting resolution from 384x288 to 352x288.
--- Capturing frame...
VIDIOC_DQBUF: No such device
No frames captured.

i can't proceed anymore with my project. this is my first arduino project.so everything is very confusing to me.,please help :(
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: Gl1der on Jan 29, 2017, 07:27 pm
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

I know it has been a long time since this was posted but I just tried it today (1/29/2017) and it works great!  So much easier and quicker!  Thanks a million!
Title: Re: Guide to Setup Streaming Web Cam on the Yun
Post by: zamar10 on Jun 13, 2018, 03:35 pm
Hi Daniel,

I´m working in something like what you do. The idea is to take photos an instead of storage the information in a SD card, transfer directly to a PC.

To do this, I'm using an Arduino Yun.

Can you help me? I don't know how to do it.

Thanks a lot.