Connecting a webcam and using the router to stream video around the place should be one of the easiest things to do. A bit too easy in that I neglected to provide simple instructions on how to set it up.
mjpg-streamer and the necessary drivers are included in the standard images I provide on the TP-Link TL-WR703N project page.
Preliminary steps :-
- Get a router, load it with the standard image.
- Set-up wireless or any other networking changes. See an example here.
- Plug in the camera
Now there are two ways to get mjpg-streamer to auto-start, there is an easy way and an elegant way.
- Easy way : Just add the command to the auto start script using LuCi…
- Elegant way : Edit the configuration files /etc/init.d/mjpg-streamer and /etc/config/mjpg-streamer
I prefer the easy way you are less likely to screw it up. First we should check that the camera works well with mjpg-streamer…
- Telnet/SSH into the router
- Run the following command :
mjpg_streamer -i “./input_uvc.so -n -r VGA -f 6 -d /dev/video0” -o “./output_http.so -p 8080 -n”
This command uses VGA (640×480) resolution “-r VGA” at 6 frames per second “-f 6”.
- If that doesn’t work and an error appears, it most likely means your camera doesn’t support JPEG images. If so, try the following command instead :
mjpg_streamer -i “./input_uvc.so -n -q 60 -r QVGA -f 6 -d /dev/video0” -o “./output_http.so -p 8080 -n”
This command forces mjpg-streamer to convert into raw into JPEG at (-q) quality 60, at resolution (-r) QVGA, this can be “160×120” for example. The frame rate is specified by the -f (6). This method is MUUUUUUUUCH more CPU intensive and you might have to tweak the resolution and frame rate down.
- Using a device connected to the router, use a web browser (e.g. Chrome) to connect to the following to get a live view:
You can also get a single snapshot at:
- If you need to play around with the commands, use CTRL-C to kill mjpg-streamer and try again. Avoid high resolutions (e.g. 1920×1080) as that will just crash the router. I used 640×480 at 25 frames per second relatively happily on a JPEG enabled camera (e.g. Logitech/Microsoft ones, not the cheap no brand ones).
- Once you have a workable set-up, copy the command you have and put it into the local start-up. Append the command line with an ampersand “&” so it runs in the background. e.g.
mjpg_streamer -i “./input_uvc.so -n -r VGA -f 6 -d /dev/video0” -o “./output_http.so -p 8080 -n” &
Hint – In Luci, select the Systems tab, then select Startup, scroll down to the Local Startup section and add your command to the box and press save and apply.