Skip to content

Live Streaming with Pi

Ajay Ramachandran edited this page Nov 25, 2021 · 1 revision

The raspberry pi can be used as a camera feed forwarder. To do this, connect a USB capture card to the pi, and it will act like a normal video source.

If using a runcam, this can be connected with an AV capture card and a micro USB to TV-Out cable.

Cable connection

On the rasperry pi, install ffmpeg, and nginx with the rtmp module

sudo apt install ffmpeg nginx libnginx-mod-rtmp -y

Setup the nginx config to be an RTMP forwarder with a low buffer (to reduce latency)

load_module /usr/lib/nginx/modules/ngx_stream_module.so;
load_module /usr/lib/nginx/modules/ngx_rtmp_module.so;

worker_processes 1;

events {

}

rtmp {
    server {
        listen 1935;
        chunk_size 2096;

        application live {
            live on;
            record off;
        }
    }
}

Restart the nginx service

sudo service nginx reload

You can now stream the video signal with ffmpeg

ffmpeg -re -i /dev/video0 -f flv -b:v 3000k rtmp://localhost/live

If there are multiple cameras connected, increment the number beside /dev/video


You can view this steam in OBS or VLC by opening up a network stream with rtmp://<IP of RaspberryPi>/live. In OBS, you use a "Media Source".

OBS screenshot

Clone this wiki locally