Guide to Setup Streaming Web Cam on the Yun

Plan A:

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

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 ::slight_smile: , 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

I'm making progress!

Instead of:

trippingly:
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)... :grinning:

stefanos90:
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

@bobli,
this question has been answer multiple times. Please start a new thread.

TIA
Jesse

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?

Sample html page from blablabla.local:8080:

<html>
  <head>
    <title>MJPG-Streamer - Stream Example</title>
  </head>
  <body>
    <center>
      <img src="/?action=stream" />
    </center>
  </body>
</html>
nano /www/video.html
<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

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 "" to put in my own page....

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...

nano /www/cgi-bin/mjpg-restart.cgi
#!/bin/ash
/etc/init.d/mjpg-streamer restart
echo "Content-type: text/html"
echo ""
echo "Restart..."
exit 0
chmod 755 /www/cgi-bin/mjpg-restart.cgi

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

nano /www/webcam/stream.html
...
<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

substitute start,stop for restart if you needed.

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?

Solved it with this :slight_smile:

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

and

nano /www/cgi-bin/mjpg-restart.cgi
#!/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 to help cooling the precessor...

Hasr:
Solved it with this :slight_smile:

nano /www/webcam/stream.html
...
    ... > ``` > > > > and > > > > ``` > nano /www/cgi-bin/mjpg-restart.cgi > ``` > > > > > > ``` > #!/bin/ash echo "Content-type: text/html" echo echo "Stream Restart

Restart in 10 seconds..."

/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.

Hasr:
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 to help cooling the precessor...

http://forum.arduino.cc/index.php?topic=324160.0

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.

https://forum.arduino.cc/index.php?topic=188690.msg1503132#msg1503132

hi Guys! i hope someone is still active to help me :cry:

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 :frowning:

MadScience:
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: USB Video Support [Old OpenWrt Wiki]. 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 - Webcam with the Linux UVC driver [Old OpenWrt Wiki]. I just ran it with the following command
 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

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!

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.