【问题标题】:ffmpeg can't change number of B-framesffmpeg 无法更改 B 帧的数量
【发布时间】:2021-08-15 21:57:52
【问题描述】:

当从源流式传输时,我会按照相同的模式不断接收帧: I-frame P-frame I-frame P-frame I-frame P-frame ...。 我尝试了许多选项并在这里阅读了尽可能多的问题,但我找不到增加 P 帧数量或至少启用 B 帧的方法。

主要是我似乎应该使用:

 ffprobe rtsp://localhost/video -g 30 -bf 3 -show_frames -of csv

我做错了什么?

【问题讨论】:

标签: ffmpeg streaming h.264


【解决方案1】:

使用-bf 选项,您可以设置 B 帧的数量。

但您必须使用ffmpeg 重新编码输入以更改 GOP 结构。

举个例子:

ffmpeg -i input.mp4 -c:v libx264 -g 12 -bf 2 -flags +cgop output.mp4

生成的输出应具有以下 GOP 结构:

position 1 2 3 1 2 3 1 2 3 1 2 3
frame I B B P B B P B B P B B I

在 shell 上,您可以使用 ffprobe 轻松输出 GOP 结构。

分析2秒的文件:

ffmpeg -i input.mp4 -map 0 -c copy -t 2 -f nut pipe: | ffprobe pipe: -show_frames | grep pict_type

【讨论】:

  • 没有grep: ffprobe -v error -show_entries frame=pict_type -of csv=p=0 -
  • 所以我必须重新编码视频,对吗?因为我的目标是减少 CPU 使用率。
猜你喜欢
  • 2021-08-08
  • 2018-03-08
  • 2012-07-05
  • 1970-01-01
  • 2017-10-28
  • 1970-01-01
  • 2021-04-13
  • 1970-01-01
  • 2013-03-29
相关资源
最近更新 更多