In this little snippet / howto I’m going to show how I got a regular Logitech webcam streaming over the internet.

So let’s start with the problem:
I have a fishtank, I wanted to create a “fish cam” :)

Step 1 - Hardware

So I have a regular Logitech HD Webcam C910, and a standard Debian stretch sitting on a PC next to my fishtank.

Pretty straight forward so far, I do have contrib and non-free repos enabled

deb http://deb.debian.org/debian/ stretch main non-free contrib
deb-src http://deb.debian.org/debian/ stretch main non-free contrib

deb http://security.debian.org/debian-security stretch/updates main contrib non-free
deb-src http://security.debian.org/debian-security stretch/updates main contrib non-free

Step 2 - The streaming software

Motion - link

Here’s a wee quote from the website

Motion is a highly configurable program that monitors video signals from many types of cameras. Set it up to monitor your security cameras, watch birds, check in on your pet, create timelapse videos and more.

Wow, that’s what I want to do - check in on my pets :)

So let’s install it:

aptitude install motion

TADA !!!!

No let’s configure it.

I don’t want to keep images, I just want to stream, so the steps I need to do are:

  1. Create a conf directory in my home directory
  2. Create a config file in the created config directory

So let’s create a directory by doing
mkdir ~/.motion

No let’s create a config file by doing
vi ~/.motion/motion.conf

Note: probably don’t do this as user root

Let’s look at my config

stream_port 9091
stream_localhost off
webcontrol_localhost off
webcontrol_port 9092
minimum_motion_frames 1
output_pictures off
quality 100
stream_quality 100

Basically, the needed bits are stream_port 9091, stream_localhost off, and output_pictures off.
This sets the tcp port you want to use, disables “localhost” only, and turns off saving images.

Run the server

Here’s the fun bit.
motion

That’s it, you have a streaming server up and running. You can view it by open a browser and going to http://your.ip.address:9091/

Wrapping up

So to get this all up and running (and public if you want that) you have to open a tcp port on your firewall.
I use Mikrotik, so here is what I do:

/ip firewall nat
chain=dstnat action=dst-nat to-addresses=10.0.0.2 to-ports=9091 protocol=tcp in-interface=ether1 dst-port=9091 log=no log-prefix=""

and of course you want to see it running, so here’s a link:
Fishcam (webcam streaming)
A wee note: I built a small php proxy script that looks like this:

<?php
set_time_limit(0);
$fp = fsockopen ("my.public.ip", 9091, $errno, $errstr, 30);
if (!$fp) {
    echo "$errstr ($errno)<br>\n";
} else {
    fputs ($fp, "GET / HTTP/1.0\r\n\r\n");
    while ($str = trim(fgets($fp, 4096)))
       header($str);
    fpassthru($fp);
    fclose($fp);
}
?>

1 Comment

Leave a Comment

Liked what you've read?

  1. Leave me a message, or
  2. Drop me an email

It only takes a second of your time, but it means the world to me.
Don't comment on Facebook, comment here !

I don't keep any of your information, I only ask for a name, and an email to stop spammers!
Pretty please !! :)

Your email address will not be published. Required fields are marked *

You won't be notified of replies, so come back and visit again!

☝️ Top
🏠 Home