Quick Start with FFmpeg+Nodejs

I just assigned a work to use FFmpeg and streaming a video from local machine(such as Laptop or PC) to another local machine over the network. After two days of google I came out with FFmpeg+Nodejs Video Streaming Example which I test it on windows only.

Getting Started

Installation

first of all install all software you need.

  1. Install nodejs
  2. Install ffmpeg
  3. Install VLC media player

FFmpeg Basic Video Streaming Command

  1. Start with FFmpeg-DirectShow (see official DOCUMENT)
Let see the list of webcam device in you local machine. Copy this following command and run it in your command line. It would show list of the device with their names.
ffmpeg -list_devices true -f dshow -i dummy
Example result with my video device name Lenovo EasyCamera
list of video and audio devices
Next, Lets try to record the video and save it. Before run this command don’t forget to change video=”YOUR VIDEO DEVICE NAME”, then run it.
ffmpeg -f dshow -i video=”Lenovo EasyCamera” out.mp4
After run this for a while and terminate this running command, you would see out.mp4 in your directory

2. Go for Video Streamming (see official DOCUMENT)

Running this following command to start a video client streaming
ffmpeg -f dshow -i video=”Lenovo EasyCamera” -vcodec libx264 -tune zerolatency -b 900k -f mpegts udp://localhost:1234
How to watch this video streaming open VLC media player right away!
After that open VLC go to Media->Open Network Stream… or use short key Ctrl+N. Fill in network URL: with udp://@localhost:1234. Don’t forget @.
Press Play button below and wait. you would see the your video device streaming.
vlc

Open Video Streaming in Web Browser instead of VLC

Download the example. Use the following command in cmd as order below.
git clone https://github.com/pacozaa/rtsp-ffmpeg.git
cd rtsp-ffmpeg
cd example
node server.js
Open your favorite web browser and type in the url like this localhost:6147
Press the + button then select cam 3. Wait and see the video streaming!

For more information

Visit here