Video Streaming 🔗

Video streaming 🔗

Two problems...

  1. Find a way to capture video
  2. Find a way to stream it

MJPG streamer 🔗

If your camera natively supports MJPG, this is possibly one of the best methods.

It uses the camera's hardware to compress the video (rather than your CPU - as somehow it's tough to do HW Video encoding on a computer).

Make sure it works 🔗

Check whether your camera supports MJPG:

$ v4l2-ctl --list-formats # or v4l2-ctl --list-formats-ext

Install and run mjpg-streamer 🔗

If it does, install mjpg-streamer, available on AUR.

NB: the standard package on AUR (mpjpg-streamer) seems outdated,
I suggest to use aur/mjpg-streamer-pikvm

Run:

mjpg_streamer -i "input_uvc.so -d /dev/video0 -r 480x360 -f 30" -o "output_http.so -w /usr/share/mjpeg-streamer/www/ -p 9123"

Or something similar. Try to play with resolution and FPS.

This starts an MJPG Streamer server on localhost:9123.

A direct link to the stream will be available at /?action=stream.

Broadcast the signal using mjpeg-proxy 🔗

Create a new node (npm) project, install mjpeg-proxy, buffertool, and express (and optionally morgan, for logging), then run:

const MjpegProxy = require('mjpeg-proxy').MjpegProxy;
const express = require('express');
const morgan = require('morgan');

const app = express();

app.use( morgan('combined', {immediate:true}) );
app.get( '/', new MjpegProxy('http://localhost:9123/?action=stream').proxyRequest );
app.listen( 8080 );

This will open an HTTP server on the 8080 ready to broadcast the signal.

The above step is obviously only useful if you want to use a remote server as a relay (otherwise mjpeg-streamer could broadcast on its own). If you need this, the above script needs to connect to your mjpg-streamer... To make the above example work, create a reverse tunnel for the port 9123:

ssh $RELAY_SERVER -R 9123:localhost:9123

Everything should be working at this point.

live peori 🔗

Check out live.peori.space.
You should setup your stream too, then we can have a dynamic live peori grid.

Our live peori service embeds the relay, so you only need to forward your MJPEG stream.

  1. We're gonna use the example ports 9000 for your MJPEG stream. This port is already taken, you'll have to choose another one. The following ports are taken:

    • 9000: peoro
    • 9003: yuri
    • 9123: tom
    • 9666: jimmy

    Don't forget to add your ports here.

  2. Run mjpg_streamer locally, and forward its port to peori:

    mjpg_streamer -i "input_uvc.so -d /dev/video0 -r 480x360 -f 30" -o "output_http.so -w /usr/share/mjpeg-streamer/www/ -p 9000" &
    ssh scaleway1.peori.space -R 9000:localhost:9000
    
  3. Only the first time: ask peoro to add your stream to live peori.