Skip to content

Use Mobile Phone as Camera

nitrag edited this page Jun 7, 2017 · 1 revision

Phone/Tablet as Camera

Tested with iPhone 6s
  1. This requires Nginx to be installed on your server with a custom module. Follow the instructions here: https://github.com/arut/nginx-rtmp-module/wiki/Getting-started-with-nginx-rtmp
  2. Setup Nginx conf: (/usr/local/nginx/conf/nginx.conf)
#add to the bottom
rtmp {
    server {
        listen 1935;
        chunk_size 1024;

        application live {
            live on;
            record off;
            
            #use this line to re-encode the stream (extra cpu usage and probably not necessary)   
            #exec ffmpeg -i rtmp://localhost/live/camera1 -threads 1 -c:v libx264 -profile:v baseline -b:v 500K -s 1280x720  -an -strict -2 -f flv rtmp://localhost/stream/camera1;

            #proxy the raw stream (NO, ports are NOT needed)
            exec ffmpeg -i rtmp://localhost/live/camera1 -threads 1 -c copy -an -f flv rtmp://localhost/stream/camera1;
        }
        application stream {
            live on;
            record off;
        }
    }
}
  1. Download a RTMP streamer app. I used Larix Broadcaster. Setup your connection to your server on port 1935. If connecting externally, setup Port Forwarding on your router. The URL to setup in the App should look like: rtmp://192.168.1.100:1935/stream/camera1. You can also test the URL in VLC Player on your computer.
  2. Change the App's stream encoding to whatever you like. I chose 15fps at 500kb/s with 4sec keyframe. I also disabled audio to minimize unnecessary bandwidth.

Considerations

  1. nginx-rtmp-module settings above are wide-open. Anyone can stream and listen consider locking them down. Command Reference.