ffmpeg -hide_banner -re -i video.mp4 -master_pl_name master.m3u8 ^
-vf scale=w=640:h=-2 -c:a aac -ar 48000 -c:v h264 -profile:v main -crf 20 -sc_threshold 0 -g 48 -keyint_min 48 -hls_time 4 -b:v 800k -maxrate 856k -bufsize 1200k -b:a 96k -hls_segment_filename D:\xampp\htdocs\streaming-demo\360p_%%03d.ts D:\xampp\htdocs\streaming-demo\360p_%v.m3u8 ^
-vf scale=w=842:h=-2 -c:a aac -ar 48000 -c:v h264 -profile:v main -crf 20 -sc_threshold 0 -g 48 -keyint_min 48 -hls_time 4 -b:v 1400k -maxrate 1498k -bufsize 2100k -b:a 128k -hls_segment_filename D:\xampp\htdocs\streaming-demo\480p_%%03d.ts D:\xampp\htdocs\streaming-demo\480p_%v.m3u8 ^
-vf scale=w=1280:h=-2 -c:a aac -ar 48000 -c:v h264 -profile:v main -crf 20 -sc_threshold 0 -g 48 -keyint_min 48 -hls_time 4 -b:v 2800k -maxrate 2996k -bufsize 4200k -b:a 128k -hls_segment_filename D:\xampp\htdocs\streaming-demo\720p_%%03d.ts D:\xampp\htdocs\streaming-demo\720p_%v.m3u8 ^
-vf scale=w=1920:h=-2 -c:a aac -ar 48000 -c:v h264 -profile:v main -crf 20 -sc_threshold 0 -g 48 -keyint_min 48 -hls_time 4 -b:v 5000k -maxrate 5350k -bufsize 7500k -b:a 192k -hls_segment_filename D:\xampp\htdocs\streaming-demo\1080p_%%03d.ts D:\xampp\htdocs\streaming-demo\1080p_%v.m3u8
它仅包含 360p 分辨率的播放列表链接。
答案1
您的现有命令调用了 4 个 HLS 复用器。要生成具有多个音频/视频再现的 HLS 输出,您必须调用一个 HLS 复用器,多次映射所有流(每个再现一次),并设置为var_stream_map
将这些流分组为单独的再现。
基本形式是
ffmpeg -hide_banner -re -i video.mp4 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 ^
-c:v h264 -profile:v main -crf 20 -sc_threshold 0 -g 48 -keyint_min 48 -c:a aac -ar 48000 ^
-filter:v:0 scale=w=640:h=-2 -maxrate:v:0 856k -bufsize:v:0 1200k -b:a:0 96k ^
-filter:v:1 scale=w=842:h=-2 -maxrate:v:1 1498k -bufsize:v:1 2100k -b:a:1 128k ^
-filter:v:2 scale=w=1280:h=-2 -maxrate:v:2 2996k -bufsize:v:2 4200k -b:a:2 128k ^
-filter:v:3 scale=w=1920:h=-2 -maxrate:v:3 5350k -bufsize:v:3 7500k -b:a:3 192k ^
-var_stream_map "v:0,a:0 v:1,a:1 v:2,a:2 v:3,a:3" -hls_time 4 -master_pl_name master.m3u8 ^
-hls_segment_filename D:\xampp\htdocs\streaming-demo\seg_%v_%03d.ts D:\xampp\htdocs\streaming-demo\pl_%v.m3u8
%
如果您在 DOS 批处理文件中运行此程序,则可能需要退出。