Simple implementation of m3u8 Nginx+ffmpeg

Source: Internet
Author: User

first, the concept

M3U8 is a format for segmenting request data to implement streaming media technology

second, the installation of Nginx

Download First: Http://nginx.org/download/nginx-1.5.10.zip

Modify the MIME Plus in config:

Application/x-mpegurl m3u8;
Application/vnd.apple.mpegurl m3u8;
VIDEO/MP2T ts;

To modify the domain name port configuration, double-click Nginx.exe to run the specific installation reference: Windows Next-minute configuration Ngnix implement HLS m3u8 on demand

third, installation FFmpeg

Example of multimedia to m3u8 command:

1.64Kbps Audio EncodingAccording to the Apple-related HLS audio rules, you cannot use a stream with an audio stream peak of more than 64kbps, so currently using the audio stream as the 56kbps command is as follows: ffmpeg-i the.interview.2014.bluray.720p.x264.aac-phd.mp4-vn \ -b:a 56000 \ -hls_time \ -hls_list_size 0 \ -hls_allow_cache 1 \ -hls_base_url http://127.0.0.1:8080/audios/\ -hls_segment_filename/users/kuoxin/movies/56k/' ti2014_56k_%05d.ts ' \ /users/kuoxin/movies/56k/56k_aac.m3u8 2. Mobile network 264Kbps video encodingFrame rate: 12 Size: 416 x 234 stream: 264Kbps Video: 200Kbps Audio: 56Kbps Audio Sampling: 48KHz MP4 Description: baseling3.0:10s command is as follows: $ ffmpeg-i the.interview.2014.bluray.720p.x264.aac-phd.mp4 \ -c:v libx264 \ - r \ N - s 416x234 \ -b:v 200k \ -profile:v baseline \ -b:a 56k \ -hls_time \ -hls_list_size 0 \ -hls_allow_cache 1 \ -hls_base_url http://127.0.0.1:8080/videos/264k/\ -hls_segment_filename/users/kuoxin/movies/264k/' ti2014_264k_%05d.ts ' \ /users/kuoxin/movies/264k/264k_mp4.m3u8 3. Mobile network 464Kbps video encodingFrame rate: 15 Size: 480 x 270 stream: 464Kbps Video: 400Kbps Audio: 56Kbps Audio Sampling: 48KHz MP4 Description: Baseline Duration: 10s $ ffmpeg-i the.interview.2014.bluray.720p.x264.aac-phd.mp4 \ -c:v libx264 \ - r \ N - s 480x270 \ -b:v 400k \ -profile:v baseline \ -b:a 56k \ -hls_time \ -hls_list_size 0 \ -hls_allow_cache 1 \ -hls_base_url http://127.0.0.1:8080/videos/464k/\ -hls_segment_filename/users/kuoxin/movies/464k/' ti2014_464k_%05d.ts ' \ /users/kuoxin/movies/464k/464k_mp4.m3u8 4. Wifi/cell 664Kbps Video EncodingFrame rate: Current frame size of Video: 640 x 360 stream: 664Kbps Video: 600Kbps tone Frequency: 56Kbps Audio sampling: 48KHz MP4 Description: Baseline Duration: 10s $ ffmpeg-i the.interview.2014.bluray.720p.x264.aac-phd.mp4 \ -c:v libx264 \ - s 640X360 \ -b:v 400k \ -profile:v baseline \ -b:a 56k \ -hls_time \ -hls_list_size 0 \ -hls_allow_cache 1 \ -hls_base_url http://127.0.0.1:8080/videos/664k/\ -hls_segment_filename/users/kuoxin/movies/664k/' ti2014_464k_%05d.ts ' \ /users/kuoxin/movies/664k/664k_mp4.m3u8 4. WiFi 1294Kbps Video EncodingFrame rate: Current frame size of Video: 640 x 360 stream: 1296Kbps Video: 1200Kbps Audio: 96Kbps Audio sampling: 48KHz MP4 Description: Baseline Duration: 10s $ ffmpeg-i the.interview.2014.bluray.720p.x264.aac-phd.mp4 \ -c:v libx264 \ - s 640X360 \ -b:v 1200k \ -profile:v baseline \ -b:a 96k \ -hls_time \ -hls_list_size 0 \ -hls_allow_cache 1 \ -hls_base_url http://127.0.0.1:8080/videos/1296k/\ -hls_segment_filename/users/kuoxin/movies/1296k/' ti2014_1296k_%05d.ts ' \ /users/kuoxin/movies/1296k/1296k_mp4.m3u8 5. WiFi 3596Kbps Video EncodingFrame rate: The current frame size of the video: 960 x 540 stream: 3596Kbps (current maximum stream only: 1780Kbps) Video:          3500Kbps (current maximum stream only: 1648Kbps) Audio: 96Kbps Audio sampling: 48KHz MP4 Description: Main Duration: 10s $ ffmpeg-i the.interview.2014.bluray.720p.x264.aac-phd.mp4 \ -c:v libx264 \ - s 960X540 \ -b:a 128k \
-hls_time \ -hls_list_size 0 \ -hls_allow_cache 1 \ -hls_base_url http://127.0.0.1:8080/videos/3596k/\ -hls_segment_filename/users/kuoxin/movies/3596k/' ti2014_3596k_%05d.ts ' \ /users/kuoxin/movies/3596k/3596k_mp4.m3u8 6. WiFi 5128Kbps Video EncodingFrame rate: Video Current frame size: 720 stream x: 5128k (current maximum stream only: 1780Kbps) Video:          5000Kbps (current maximum stream only: 1648Kbps) Audio: 128Kbps Audio sampling: 48KHz MP4 Description: Main Duration: 10s      $ ffmpeg-i the.interview.2014.bluray.720p.x264.aac-phd.mp4 \ -c:v libx264 \ -b:a 128k \
-hls_time \ -hls_list_size 0 \ -hls_allow_cache 1 \ -hls_base_url http://127.0.0.1:8080/videos/5128k/\ -hls_segment_filename/users/fengkun/movies/kuoxin/' ti2014_5128k_%05d.ts ' \ /users/kuoxin/movies/5128k/5128k_mp4.m3u8

For specific reference this post use FFmpeg to generate HLS video

Note:-hls_base_url refers to the URL prefix for TS files, where TS files can be placed anywhere

-------------------------------------------------------------------

Then the request is done, the browser does not support can install a VLC, open the network Liu see if you can open

Related Reference Links:

use FFmpeg to generate HLS videos-http://www.cnblogs.com/kuoxin/p/4623642.htmlwindows Next minute configuration Ngnix implementation HLS m3u8 on demand-http://www.cnblogs.com/fx2008/p/4226974.html

Simple implementation of m3u8 Nginx+ffmpeg

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.