Difference between revisions of "Nginx: Konfigurasi RTMP dengan HLS dan Dash"
Jump to navigation
Jump to search
Onnowpurbo (talk | contribs) |
Onnowpurbo (talk | contribs) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 90: | Line 90: | ||
Contoh sederhana untuk men-stream sebuah video .avi menggunakan ffmpeg: | Contoh sederhana untuk men-stream sebuah video .avi menggunakan ffmpeg: | ||
− | + | ffmpeg -loglevel verbose -re -i movie.avi -vcodec libx264 | |
− | + | -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1 | |
− | + | -f flv rtmp://localhost:1935/hls/movie | |
+ | atau | ||
+ | |||
+ | avconv -loglevel verbose -re -i movie.avi -vcodec libx264 | ||
+ | -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1 | ||
+ | -f flv rtmp://localhost:1935/hls/movie | ||
+ | |||
+ | |||
+ | ffmpeg -loglevel verbose -re -i source.mp4 -c:v libx264 -crf 19 | ||
+ | -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1 | ||
+ | -f flv rtmp://localhost:1935/hls/movie | ||
− | |||
− | |||
− | |||
Default playlist address pada setup ini adalah: | Default playlist address pada setup ini adalah: | ||
http://server.ip/hls/StreamKey.m3u8 | http://server.ip/hls/StreamKey.m3u8 | ||
+ | |||
+ | contoh | ||
+ | |||
+ | http://192.168.0.3/hls/movie.m3u8 | ||
StreamKey pada contoh ffmpeg commandline di atas adalah “movie”. Ingat, address rtmp address selalu rtmp://ip/ApplicationName/StreamKey. | StreamKey pada contoh ffmpeg commandline di atas adalah “movie”. Ingat, address rtmp address selalu rtmp://ip/ApplicationName/StreamKey. | ||
+ | ==Sisi Client== | ||
+ | Di sisi client tampaknya kita perlu menginstalasi CODEC khususnya untuk mendukung H.264. | ||
− | + | apt-get install gstreamer1.0-plugins-bad gstreamer1.0-plugins-bad-dbg \ | |
+ | gstreamer1.0-plugins-bad-doc gstreamer1.0-plugins-bad-faad \ | ||
+ | gstreamer1.0-plugins-bad-videoparsers gstreamer1.0-plugins-ugly \ | ||
+ | totem-plugins totem-plugins-extra gstreamer0.10-plugins-bad \ | ||
+ | gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-ugly \ | ||
+ | gnome-codec-install gstreamer0.10-plugins-bad \ | ||
+ | gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-base \ | ||
+ | gstreamer0.10-plugins-base-apps gstreamer0.10-plugins-good \ | ||
+ | gstreamer0.10-plugins-ugly gstreamer0.10-x gstreamer0.10-tools | ||
Latest revision as of 07:31, 2 November 2014
Untuk mendukung HLS & Dash, kita perlu mengubah sedikit konfigurasi nginx.conf
vi /usr/local/nginx/conf/nginx.conf
ubah agar
http { server { listen 80; location /hls { # Serve HLS fragments types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; } root /tmp; add_header Cache-Control no-cache; } location /dash { # Serve DASH fragments root /tmp; add_header Cache-Control no-cache; } } }
Kita butuh menambahkan folder tmp/dash and tmp/hls di root folder untuk nginx.
mkdir /tmp/hls mkdir /tmp/dash chmod -Rf 777 /tmp/hls chmod -Rf 777 /tmp/dash
Juga di bagian rtmp:
rtmp { server { listen 1935; chunk_size 4000; application live { live on; record off; } application hls { live on; hls on; hls_path /tmp/hls; } # MPEG-DASH is similar to HLS application dash { live on; dash on; dash_path /tmp/dash; } } }
Contoh lain untuk hls
location /hls/ { hls; # Use the HLS handler to manage requests # serve content from the following location alias /var/www/video; # HLS parameters hls_fragment 8s; hls_buffers 10 10m; hls_mp4_buffer_size 1m; hls_mp4_max_buffer_size 5m; }
Contoh sederhana untuk men-stream sebuah video .avi menggunakan ffmpeg:
ffmpeg -loglevel verbose -re -i movie.avi -vcodec libx264 -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1 -f flv rtmp://localhost:1935/hls/movie
atau
avconv -loglevel verbose -re -i movie.avi -vcodec libx264 -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1 -f flv rtmp://localhost:1935/hls/movie
ffmpeg -loglevel verbose -re -i source.mp4 -c:v libx264 -crf 19 -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1 -f flv rtmp://localhost:1935/hls/movie
Default playlist address pada setup ini adalah:
http://server.ip/hls/StreamKey.m3u8
contoh
http://192.168.0.3/hls/movie.m3u8
StreamKey pada contoh ffmpeg commandline di atas adalah “movie”. Ingat, address rtmp address selalu rtmp://ip/ApplicationName/StreamKey.
Sisi Client
Di sisi client tampaknya kita perlu menginstalasi CODEC khususnya untuk mendukung H.264.
apt-get install gstreamer1.0-plugins-bad gstreamer1.0-plugins-bad-dbg \ gstreamer1.0-plugins-bad-doc gstreamer1.0-plugins-bad-faad \ gstreamer1.0-plugins-bad-videoparsers gstreamer1.0-plugins-ugly \ totem-plugins totem-plugins-extra gstreamer0.10-plugins-bad \ gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-ugly \ gnome-codec-install gstreamer0.10-plugins-bad \ gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-base \ gstreamer0.10-plugins-base-apps gstreamer0.10-plugins-good \ gstreamer0.10-plugins-ugly gstreamer0.10-x gstreamer0.10-tools