FFMPEG H264压缩预设会影响视频质量吗?

ang*_*nor 8 ffmpeg

我绝对不是FFMPEG专家,但根据这份文件:

预设是一组选项,可以提供一定的编码速度与压缩比.较慢的预设将提供更好的压缩(压缩是每个文件大小的质量).一般用法是使用您耐心等待的最慢预设.按速度降序排列的当前预设为:超快,超快,非常快,快,快,中,慢,慢,小,安慰剂.

据我了解,ffmpeg预设不应影响输出视频的质量,而应仅确定压缩比/输出文件大小.因此,假设相同的质量设置(我将使用-crf 24),文件应该比例如faster预设的slower预设大.这将是使用较慢预设的唯一原因 - 获得较小的文件大小.

事实证明并非如此.我使用不同的预设从handycam编码高清流,其他一切都是相同的:

ffmpeg -y -i "$fname" -vf yadif=1,scale=-1:720 -acodec aac -ab 128k -ac 2 -strict experimental -vcodec libx264 -vpre slow -threads 2 -crf 24 "$outp"
Run Code Online (Sandbox Code Playgroud)

令人惊讶的是,我获得了veryfast预设的最小文件大小!例如:

  • slower:输出比特率3500kbps,编码速度17 fps,文件大小29MB
  • veryfast:输出比特率3050kbps,编码速度34 fps,文件大小25MB

我认为不应该如此.现在我想知道,是因为veryfast预设的编码质量较差?或者在我使用的情况下,slower由于某种原因根本没有意义?

llo*_*gan 12

是的,根据所使用的预设,质量可能略有不同,但不应该是一个重要的数量.以下是#x264讨论的摘录.您的一个x264开发人员提供的答案与您的类似问题:

verb3k | Do different presets have an effect on quality when used with CRF?
@Dark_Shikari | verb3k: yes, but not too much.
@Dark_Shikari | a 0th-order approximation is that they have no effect.
@Dark_Shikari | The main reason there's a difference is because the preset affects how x264 itself measures quality
@Dark_Shikari | that is, it uses better, more accurate methods of measuring quality
@Dark_Shikari | obviously, this will affect the definition of what -crf does!
@Dark_Shikari | It's just not too much, so we can mostly ignore it.
@Dark_Shikari | specifically, there are three big things that can affect the definition of quality
@Dark_Shikari | 1) AQ being on/off
@Dark_Shikari | jump: ultrafast to superfast
@Dark_Shikari | 2) mbtree being on/off
@Dark_Shikari | jump: superfast to veryfast
@Dark_Shikari | 3) psy-rd being on/off
@Dark_Shikari | jump: faster to fast
@Dark_Shikari | above fast there are no more big jumps.
Run Code Online (Sandbox Code Playgroud)

这意味着具有相同CRF值的较慢预设将提高每比特率的质量,但可能使质量和比特率更高更低.


小智 5

如果它有帮助,这里是一个git difffrom slowerto veryfast。即使您只考虑ref价值,您也可以看出veryfast质量如何会降低。

ref
In short, this value is the number of previous frames each P-frame can use
as references.
Run Code Online (Sandbox Code Playgroud)

来源

--- a/slower
+++ b/veryfast
@@ -1,20 +1,20 @@
 cabac=1
-ref=8
+ref=1
 deblock=1:0:0
-analyse=0x3:0x133
-me=umh
-subme=9
+analyse=0x3:0x113
+me=hex
+subme=2
 psy=1
 psy_rd=1.00:0.00
-mixed_ref=1
+mixed_ref=0
 me_range=16
 chroma_me=1
-trellis=2
+trellis=0
 8x8dct=1
 cqm=0
 deadzone=21,11
 fast_pskip=1
-chroma_qp_offset=-2
+chroma_qp_offset=0
 threads=12
 lookahead_threads=2
 sliced_threads=0
@@ -25,17 +25,17 @@ bluray_compat=0
 constrained_intra=0
 bframes=3
 b_pyramid=2
-b_adapt=2
+b_adapt=1
 b_bias=0
-direct=3
+direct=1
 weightb=1
 open_gop=0
-weightp=2
+weightp=1
 keyint=250
 keyint_min=23
 scenecut=40
 intra_refresh=0
-rc_lookahead=60
+rc_lookahead=10
 rc=crf
 mbtree=1
 crf=23.0
Run Code Online (Sandbox Code Playgroud)