gaiar
6/20/2018 - 7:22 AM

Stream Raspberry Pi

wget http://nginx.org/download/nginx-1.9.11.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/v1.1.7.tar.gz
tar xzf nginx-1.9.11.tar.gz
tar xzf v1.1.7.tar.gz
pacman -Sy base-devel ffmpeg nginx
cd nginx-1.9.11
./configure \
    --prefix=/etc/nginx \
    --conf-path=/etc/nginx/nginx.conf \
    --sbin-path=/usr/bin/nginx \
    --pid-path=/run/nginx.pid \
    --lock-path=/run/lock/nginx.lock \
    --user=http \
    --group=http \
    --http-log-path=/var/log/nginx/access.log \
    --error-log-path=stderr \
    --http-client-body-temp-path=/var/lib/nginx/client-body \
    --http-proxy-temp-path=/var/lib/nginx/proxy \
    --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
    --http-scgi-temp-path=/var/lib/nginx/scgi \
    --http-uwsgi-temp-path=/var/lib/nginx/uwsgi \
    --with-mail \
    --with-mail_ssl_module \
    --with-ipv6 \
    --with-pcre-jit \
    --with-file-aio \
    --with-http_dav_module \
    --with-http_gunzip_module \
    --with-http_gzip_static_module \
    --with-http_realip_module \
    --with-http_v2_module \
    --with-http_ssl_module \
    --with-http_stub_status_module \
    --with-http_addition_module \
    --with-http_degradation_module \
    --with-http_flv_module \
    --with-http_mp4_module \
    --with-http_secure_link_module \
    --with-http_sub_module \
    --with-threads \
    --with-stream \
    --add-module=../nginx-rtmp-module-1.1.7
make
cp ./objs/nginx /usr/sbin/nginx
cat >> /etc/nginx/nginx.conf <<_EOF_
rtmp {
    server {
        listen 1935;
        application live {
            live on;
        }
    }
}
_EOF_
nginx -t
systemctl start nginx
# stream local video
ffmpeg -re -i video.mp4 -f flv rtmp://localhost/live/video
# stream local webcam
ffmpeg -f video4linux2 -r 24 -i /dev/video0 -f flv rtmp://localhost/
live/webcam
# stream remote webcam (on MacOSX)
ffmpeg -f qtkit -i 0 -f flv rtmp://192.168.1.151/live/webcam
# view live stream (on MacOSX)
vlc rtmp://192.168.1.151/live/webcam
# stream raspberry pi camera (pi -> bridge -> remote -> local)
nc -vlkp 8888 | ffmpeg -i - -f flv rtmp://datageek.info/live/webcam
/opt/vc/bin/raspivid -o - -t 0 -hf -w 640 -h 360 -fps 25 | nc -v 192.168.1.196 8888
vlc rtmp://datageek.info/live/webcam