Streaming Video over WiFi
This week we’ll show you how to stream video over your WiFi network using the Omega and a USB webcam. We’ll be using the mjpg-streamer program to help us out with this endeavor. This method is actually used in the Webcam app on the Onion Console!
First, let’s install the program. Run the two commands below:
opkg update opkg install mjpg-streamer
Now we need to configure the program and change some default settings. Open up the mjpg-streamer configuration file:
First, to make our initial testing and implementation easier, let’s remove the need for a username and password by deleting the following lines:
option username 'openwrt' option password 'openwrt'
You can add these back in later if you want the additional security!
Now let’s increase the frames per second (FPS) from the default. Change the option fps ‘5’ line to option fps ‘15’ .
We’re almost ready! Enable the webcam by changing option enabled ‘0’ to option enabled ‘1’. Save the file and move on to the next step.
Now we’re set! Start the stream by running the following command:
The main event: let’s watch the video stream now! On your computer, open up a web browser and navigate to:
Replace the XXXX with the bolded digits on your Omega’s shielding. You’ll now see the video feed. Wave to the camera! Also, try pointing it at your computer screen and see what happens!
Now you can use your Omega to wirelessly stream video on your WiFi network!
You can also take snapshots with the webcam using the web interface. Navigate to:
Try refreshing the page; every time it loads, it will take a snapshot and display it in your browser!
As a bonus, you can also set up the webcam to start streaming automatically whenever the Omega boots. Run the following command once to enable this:
To close the stream, stop the webcam service by running:
You can also stop the stream by disabling the webcam in the configuration file, then restarting the service: Open up the configuration file with vi /etc/config/mjpg-streamer, then change option enabled ‘1’ to option enabled ‘0’. Then restart the service with /etc/init.d/mjpg-streamer restart.
And that’s it! Happy streaming!
Thanks for reading & have a great week!
Let us know what kind of stuff you would like to see featured on 2-Bullet Tuesday! Send a tweet to @OnionIoT with your suggestions!
P.S. Get free shipping on all Onion Store orders over $75 that include a Dock, Expansion, or a Kit!