ffmpeg 视频保持源的参考帧

ffmpeg video keep ref frame of source

我喜欢保留源的一些参考帧(在本例中 ref =1):

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L3
Format settings                          : CABAC / 1 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 1 frame
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 6 min 19 s
Bit rate                                 : 388 kb/s
Width                                    : 640 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 4:3
Frame rate mode                          : Variable
Frame rate                               : 9.479 FPS
Minimum frame rate                       : 3.750 FPS
Maximum frame rate                       : 30.030 FPS
Original frame rate                      : 30.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.133
Stream size                              : 17.5 MiB (74%)
Language                                 : English
Codec configuration box                  : avcC

这里是输出

   ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : High@L3
    Format settings                          : CABAC  2 Ref Frames
    Format settings, CABAC                   : Yes
    Format settings, Reference frames        : 2 frames
    Codec ID                                 : avc1
    Codec ID/Info                            : Advanced Video Coding
   

输出的Ref Frames是2,但我喜欢保持1或者直接强制1。

有办法吗?

谢谢!

对于编码器 libx264 添加 -refs 1 -bf 0.

Option Description
-refs Number of reference frames
-bf Number of b-frames
  • mediainfo 似乎将参考帧和 b 帧都计算为 Format settings, Reference frames 总数(但我没有验证)。
  • 或者,您可以使用 -preset ultrafast 而不是 -refs 1 -bf 0,它会自动设置 -refs 1 -bf 0。但是,不推荐这样做,因为它也会更改许多其他设置,并且是效率最低(但最快)的预设。