Build Live Video Streaming Server using ffmpeg Nginx Rtmp Module & Nodejs

2 min readDec 13, 2017


[Video Coming soon] In this tutorial series i will use Ffmpeg, Nginx + Nginx-rtmp-module + Nodejs create live streaming service allow user connect their camera to their account and display live video on user’s dashboard.


  1. Live Stream, save recording file for watch later.
  2. Each user has one or many cameras with many live stream secret key. Allow Camera devices send video for streaming.
  3. View camera private , or share their camera , such as public street camera.
  4. Target devices: Raspberry pi zero w, Raspberry pi 3 with camera module (will use in this tutorial series), or other cameras, screen streaming
  5. Web app(Mobile App) use React for Front-End, Nodejs for backend api restful service + Realtime use WebSocket (Uws), and user stream service key.

Software requirements

  1. Ffmpeg:
  2. Nginx:
  3. Nginx-rtmp-module
  4. Nodejs:
  5. Reactjs:
  6. Player: hls.js
  7. MongoDB

Setup Nginx + Nginx-rtmp-module on MacOs

  1. Command: brew tap homebrew/nginx
  2. Command: brew options nginx-full
  3. Command: brew info nginx-full
  4. Command: brew install nginx-full — with-rtmp-module — with-debug

Setup FFMPEG on MacOs

  1. Option 1: downlpoad package:
  2. Option 2: use homebrew on Mac:
  3. Use Brew to install brew install ffmpeg
  4. Or brew info ffmpeg: brew install ffmpeg \
    — with-tools \
    — with-fdk-aac \
    — with-freetype \
    — with-fontconfig \
    — with-libass \
    — with-libvorbis \
    — with-libvpx \
    — with-opus \
    — with-x265
  5. Update FFMPEG: brew update && brew upgrade ffmpeg
  6. Input output devices list: on Mac os: ffmpeg -f avfoundation -list_devices true -i “”
  7. Sample stream camera on mac to server: ffmpeg -f avfoundation -r 30 -i “0:0” -deinterlace -vcodec libx264 -pix_fmt yuv420p -preset medium -g 60 -b:v 2500k -acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b:a 712000 -bufsize 512k -f flv rtmp://localhost/live/tabvn
  8. Stream from a file to server: ffmpeg -re -i video.mkv -c:v libx264 -preset veryfast -maxrate 3000k -bufsize 6000k -pix_fmt yuv420p -g 50 -c:a aac -b:a 160k -ac 2 -ar 44100 -f flv rtmp://localhost/live/tabvn

Sample Nginx Config

Next Part: Setup Nginx ,Nginx-Rtmp-Module & Ffmpeg Build Live Video Streaming Server






i’m from a nice city in Vietnam called Danang, where live and did my studies. I love programming, coffee and spending my free time teaching myself new skills.