Created
September 20, 2017 22:53
-
-
Save kevinGodell/f91ae4087b0a56c138842dbb40cbfe7c to your computer and use it in GitHub Desktop.
Revisions
-
kevinGodell created this gist
Sep 20, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,72 @@ # Live streaming mpeg-dash video using ffmpeg and dash.js Use ffmpeg to connect to an ip cctv camera and create video files on the fly that can be viewed in an mpeg-dash compatible browser using dash.js and an html5 video element. ### Prerequisites ``` A linux server, such as Ubuntu Apache web server installed, running, and reachable via its ip address Latest version of Ffmpeg installed An ip camera that is reachable from the server ``` ### Configuring Server Get root access. ``` sudo su ``` Make a new directory in /dev/shm. This is crucial because we will be constantly writing files and do not want to target the hard drive. ``` mkdir /dev/shm/mpeg-dash ``` Create a symlink from /dev/shm/mpeg-dash to the public directory where apache serves files. ``` ln -s /dev/shm/mpeg-dash /var/www/html ``` Create an html file that contains the necessary code to display the mpeg-dash video. ``` cat > /var/www/html/mpeg-dash/index.html << EOF <!DOCTYPE html> <head> <meta charset="UTF-8"> <script src="https://cdn.dashjs.org/latest/dash.all.min.js"></script> <style> video { width: 640px; height: 480px; } </style> <body> <div> <video data-dashjs-player autoplay controls src="manifest.mpd" type="application/dash+xml"></video> </div> </body> </html> EOF ``` ### Generating Video Run ffmpeg with the correct parameters to connect to your ip camera and generate the mpeg-dash video files. ``` ffmpeg -i rtsp://ip_cam_address:554/user=user_password=password_channel=1_stream=0.sdp -an -c:v copy -b:v 2000k -f dash -window_size 4 -extra_window_size 0 -min_seg_duration 2000000 -remove_at_exit 1 /var/www/html/mpeg-dash/manifest.mpd ``` ### View Video Open an mpeg-dash compatible browser such as Chrome, Firefox, Safari, or IE11(Windows 8+ only). Enter the address to the directory on your server. ```http://YOUR_SERVER_IP_ADDRESS/mpeg-dash/```