ffmpeg 忽略设置的比特率

问题描述 投票:0回答:0

我有一个 h264 文件的文件夹,我正试图将其转换为 hevc,并使用 -b:v 标志设置较低的比特率。对于上下文,我使用在 Docker 容器中运行的 python。问题是当 ffmpeg 完成时,输出比特率极低。

正如您从下面的 ffmpeg 命令中看到的,我预计比特率约为 900k。但是当命令运行时,它显示大约 18k 比特率。

ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -i /tmp/input.ts -an -c:v hevc_nvenc -b:v 914k -b_ref_mode 0 -tag:v hvc1 /tmp/output.mp4 
ffmpeg version N-109685-gac37b2c2b1 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
  configuration: --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64
  libavutil      57. 44.100 / 57. 44.100
  libavcodec     59. 58.100 / 59. 58.100
  libavformat    59. 36.100 / 59. 36.100
  libavdevice    59.  8.101 / 59.  8.101
  libavfilter     8. 54.100 /  8. 54.100
  libswscale      6.  8.112 /  6.  8.112
  libswresample   4.  9.100 /  4.  9.100
-vsync is deprecated. Use -fps_mode
Passing a number to -vsync is deprecated, use a string argument as described in the manual.
Input #0, mpegts, from '/tmp/input.ts':
  Duration: 01:04:53.85, start: 85937.219044, bitrate: 2613 kb/s
  Program 1 
  Stream #0:0[0x101]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1280x720, 90k tbr, 90k tbn
  Stream #0:1[0x202]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 130 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> hevc (hevc_nvenc))
Press [q] to stop, [?] for help
Output #0, mp4, to '/tmp/output.mp4':
  Metadata:
    encoder         : Lavf59.36.100
  Stream #0:0: Video: hevc (Main) (hvc1 / 0x31637668), cuda(progressive), 1280x720, q=2-31, 914 kb/s, 90k fps, 90k tbn
    Metadata:
      encoder         : Lavc59.58.100 hevc_nvenc
    Side data:
      cpb: bitrate max/min/avg: 0/0/914000 buffer size: 1828000 vbv_delay: N/A
frame=113118 fps=412 q=49.0 Lsize=    8925kB time=01:04:53.82 bitrate=  18.8kbits/s speed=14.2x    
video:8215kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 8.636624%

然后检查输出显示它在 18kb/s 左右。

ffmpeg -i /tmp/output.mp4 
...
  Duration: 01:04:53.82, start: 0.000000, bitrate: 18 kb/s

作为参考,输入文件为 2600kb/s。

ffmpeg -i /tmp/input.ts 
...
  Duration: 01:04:53.85, start: 85937.219044, bitrate: 2613 kb/s

这似乎是文件本身的问题,因为我运行了相同的命令并让它工作。另请注意,即使我省略了 -b:v 标志,输出也大致相同。

我也尝试设置 -minrate:v -maxrate:v 和 -bufsize:v 标志,但它们没有帮助。

还有另一篇文章提到音轨是一个问题,为了排除这个问题,我尝试使用 -an 但这也没有帮助。

我看到另一篇文章提到参数的顺序是一个问题,但我认为这不是问题,因为同样的命令已在其他输入文件上成功运行。

有什么想法吗?

ffmpeg h.264 hevc
© www.soinside.com 2019 - 2024. All rights reserved.