使用多个 HLS 流对视频进行编码时ffmpeg
,主播放列表不包含CODECS
H.265 视频的属性,但它做用于 H.264 视频。这是我运行的一个命令:
ffmpeg \
-i INPUT.mov \
-i INPUT.mov \
-i INPUT.mov \
-i INPUT.mov \
-s:v:0 1920x1080 -c:a:0 aac -b:a 192k -c:v:0 libx265 -b:v:0 4000k \
-s:v:1 1280x720 -c:a:1 aac -b:a 160k -c:v:1 libx265 -b:v:1 2000k \
-s:v:2 854x480 -c:a:2 aac -b:a 160k -c:v:2 libx264 -b:v:2 1000k \
-s:v:3 640x360 -c:a:3 aac -b:a 128k -c:v:3 libx264 -b:v:3 600k \
-map 0:a \
-map 0:v \
-map 1:a \
-map 1:v \
-map 2:a \
-map 2:v \
-map 3:a \
-map 3:v \
-var_stream_map "v:0,a:0 v:1,a:1 v:2,a:2 v:3,a:3" \
-threads 0 \
-f hls \
-movflags frag_keyframe \
-hls_flags single_file \
-hls_segment_type mpegts \
-hls_list_size 0 \
-hls_time 2 \
-hls_allow_cache 1 \
-master_pl_name index.m3u8 \
-y \
master_%v.m3u8
播放列表index.m3u8
的结果如下:
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-STREAM-INF:BANDWIDTH=4540800,RESOLUTION=1920x1080
master_0.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2340800,RESOLUTION=1280x720
master_1.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1240800,RESOLUTION=854x480,CODECS="avc1.64001e,mp4a.40.2"
master_2.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=800800,RESOLUTION=640x360,CODECS="avc1.64001e,mp4a.40.2"
master_3.m3u8
注意后两个 H.264 流有CODECS="avc1.64001e,mp4a.40.2"
,但前两个 H.265 流没有CODECS
。为什么只省略 H.265 流的属性ffmpeg
?CODECS
ffmpeg
我在 macOS Catalina 10.15.6 (19G2021) 上使用4.3.1:
$ ffmpeg -version
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with Apple clang version 11.0.3 (clang-1103.0.32.62)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
答案1
ffmpeg 现在支持此功能master
:
https://trac.ffmpeg.org/ticket/8904