ffmpeg 比特率比要求的大 10%

ffmpeg bitrate 10% bigger than requested

一个简单的问题。我有一个 ffmpeg 脚本。

我请求 -b:v:0 1000k 但在我的主播放列表中得到输出 BANDWIDTH=1100000 - 我期待 BANDWIDTH=1000000

如您所见,没有音频流。为什么 BANDWIDTH 每次都比请求的比特率大 10%?

提前致谢。脚本和输出如下。

脚本:

ffmpeg -i rgb.mp4 -hide_banner # dump video stream info

rm -rf hls

ffmpeg -i rgb.mp4 \
  -v warning -preset ultrafast -g 60 -sc_threshold 0 \
  -map 0:0 -map 0:0 -map 0:0 -map 0:0 \
  -s:v:0 1440x1080 -c:v:0 libx264 -b:v:0 1000k \
  -s:v:1 1440x1080 -c:v:1 libx264 -b:v:1 2000k \
  -s:v:2 1920x1440 -c:v:2 libx264 -b:v:2 3000k \
  -s:v:3 1920x1440 -c:v:3 libx264 -b:v:3 4000k \
  -var_stream_map "v:0 v:1 v:2 v:3" \
  -master_pl_name master.m3u8 -f hls \
  -hls_time 6 -hls_list_size 0 -hls_playlist_type vod \
  -hls_segment_filename "hls/v%v/chunk%d.ts" "hls/v%v/index.m3u8"

cat hls/master.m3u8

输出:

$ sh ./ffmpeg-test-script.sh
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'rgb.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 2021-08-03T11:45:50.000000Z
    encoder         : Lavf59.4.102
  Duration: 00:00:50.04, start: 0.000000, bitrate: 37415 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1920x1440, 37412 kb/s, 30 fps, 30 tbr, 19200 tbn (default)
    Metadata:
      creation_time   : 2021-08-03T11:45:50.000000Z
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
    Side data:
      displaymatrix: rotation of -180.00 degrees
At least one output file must be specified
[swscaler @ 000001fae15daf00] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 000001faef115ec0] deprecated pixel format used, make sure you did set range correctly
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=1100000,RESOLUTION=1440x1080,CODECS="avc1.42c028"
v0/index.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=2200000,RESOLUTION=1440x1080,CODECS="avc1.42c028"
v1/index.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=3300000,RESOLUTION=1920x1440,CODECS="avc1.42c032"
v2/index.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=4400000,RESOLUTION=1920x1440,CODECS="avc1.42c032"
v3/index.m3u8

首先您指定 x264 编码器的视频比特率,它仅适用于编码器输出的比特。 HLS 播放列表中的 BANDWIDTH 参数包括容器(MPEG-2 传输流)开销。