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

时间:2013-01-13 17:34:45

标签: ffmpeg

我绝对不是FFMPEG专家,但根据this document

  

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

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

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

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"

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

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

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

2 个答案:

答案 0 :(得分:11)

是的,根据使用的预设,质量可能略有不同,但不应该是一个很大的数量。以下是#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.

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

答案 1 :(得分:4)

如果它有帮助,则git diffslowerveryfast。即使您只考虑ref值,您也可以看到veryfast的质量如何降低。

ref
In short, this value is the number of previous frames each P-frame can use
as references.

source

--- 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
相关问题