FFmpeg+Nginx+VLC打造M3U8点播
Nginx: web服务器(win10,本地nginx)
FFmpeg: m3u8切片(4.3.1)
VLC: 点播客户端
切片命令行:
ffmpeg431.exe -i ande_302.mp4 -vbsf h264_mp4toannexb -vcodec libx264 -acodec aac -strict -2 -s 640x480 -r 30 -g 60 -start_number 0 -hls_time 5 -hls_list_size 0 -threads 1 -f hls -y aaa.m3u8
H.264: avcl(MP4:KLV), annexb(附录B:Nalu)
FFmpeg+Nginx+VLC打造M3U8直播
请参考:
FFmpeg+Nginx+rtmp+videojs+VLC快速搭建网络直播网站.pdf
FFmpeg:M3U8的多码流自适应
一级索引文件(index.m3u8):
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=400,000
low.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=800,000
mid.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1500,000
hig.m3u8
二级索引文件(low.m3u8):
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:5.633333,
low0.ts
#EXTINF:4.566667,
low1.ts
#EXTINF:5.400000,
low2.ts
#EXTINF:4.966667,
low3.ts
#EXTINF:5.666667,
low4.ts
#EXTINF:5.366667,
low5.ts
#EXTINF:4.333333,
low6.ts
#EXTINF:3.700000,
low7.ts
#EXT-X-ENDLIST
切片命令:
ffmpeg431.exe -i ande_302.mp4
-vbsf h264_mp4toannexb -vcodec libx264 -acodec aac -strict -2 -s 360x270 -r 30 -g 60 -start_number 0 -hls_time 5 -hls_list_size 0 -threads 1 -f hls -y low.m3u8
-vbsf h264_mp4toannexb -vcodec libx264 -acodec aac -strict -2 -s 640x480 -r 30 -g 60 -start_number 0 -hls_time 5 -hls_list_size 0 -threads 1 -f hls -y mid.m3u8
-vbsf h264_mp4toannexb -vcodec libx264 -acodec aac -strict -2 -s 1280x720 -r 30 -g 60 -start_number 0 -hls_time 5 -hls_list_size 0 -threads 1 -f hls -y high.m3u8
Vlc请求: http://localhost/m3u8test/index.m3u8