FFMPEG 合理的默认值 [英] FFMPEG sensible defaults

查看:46
本文介绍了FFMPEG 合理的默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ffmpeg 使用 vfilter 为带有 PNG 文件的视频添加水印,如下所示:

I'm using ffmpeg to watermark videos with a PNG file using vfilters like so:

ffmpeg -i 26.wmv -vcodec libx264 -acodec copy -vf "movie=logo.png [watermark]; [in][watermark] overlay=10:10 [out]" 26_w.mkv

但是,输入文件的质量/比特率都不同,我希望输出文件的质量/比特率与输入文件相似.我将如何实现这一目标?另外,我对 ffmpeg 几乎一无所知,那么是否有任何选项可以设置为提供良好的质量:文件大小比率?

However, the input files are all of different quality/bitrates, and I want the output files to be of similar quality/bitrate to the input files. How would I achieve this? Also, I know almost nothing about ffmpeg, so are there any options which would be sensible to set to give a good quality:filesize ratio?

推荐答案

通常希望输出相同质量";因为输入是人们一直想要的假设的东西.不幸的是,这在使用有损编码器时是不可能的,而且由于色彩空间转换、色度子采样和其他问题,即使是无损编码器也可能无法提供相同的质量.但是,当使用有损编码器时,您可以获得视觉上无损(或几乎如此)的输出;这意味着它看起来好像输出与您的眼睛质量相同,但从技术上讲并非如此.此外,尝试使用与输入相同的比特率和其他参数很可能达不到您想要的效果.

Usually wanting the output to be the "same quality" as the input is an assumed thing that people will always want. Unfortunately, this is not possible when using a lossy encoder, and even lossless encoders may not provide the same quality due to colorspace conversion, chroma subsampling, and other issues. However, you can achieve visually lossless (or nearly so) outputs when using a lossy encoder; meaning that it may look as if the output is the same quality to your eyes, but technically it is not. Also, attempting to use the same bitrate and other parameters as the input will most likely not achieve what you want.

ffmpeg -i input -codec:v libx264 -preset medium -crf 24 -codec:a copy output.mkv

您可以调整的两个选项是-crf-preset.CRF(恒定速率因子)是您的质量水平.较低的值是较高的质量.预设是一组选项,可以在特定的编码速度与压缩之间进行权衡.较慢的预设将编码较慢,但会实现更高的压缩率(压缩是每个文件大小的质量).基本用法是:

The two option for you to adjust are -crf and -preset. CRF (constant rate factor) is your quality level. A lower value is a higher quality. The preset is a collection of options that will give a particular encoding speed vs compression tradeoff. A slower preset will encode slower, but will achieve higher compression (compression is quality per filesize). The basic usage is:

  1. 使用仍能提供所需质量的最高 crf 值.
  2. 使用您有耐心的最慢预设(请参阅 x264 --help 以获取预设列表并忽略 placebo 预设,因为它是个笑话).
  3. 对您的其余视频使用这些设置.
  1. Use the highest crf value that still gives you the quality you want.
  2. Use the slowest preset you have patience for (see x264 --help for a preset list and ignore the placebo preset as it is a joke).
  3. Use these settings for the rest of your videos.

其他注意事项:

  • 您不必对整个视频进行编码来测试质量.您可以使用 -ss-t 选项来选择要编码的随机部分,例如 -ss 30 -t 60 将跳过前 30 秒并创建 60 秒的输出.

    Other notes:

    • You do not have to encode the whole video to test quality. You can use the -ss and -t options to select a random section to encode, such as -ss 30 -t 60 which will skip the first 30 seconds and create a 60 second output.

      在这个例子中,音频是流复制而不是重新编码.

      In this example the audio is stream copied instead of re-encoded.

      请记住,每个编码器都是不同的,适用于 x264 的方法不适用于其他编码器.

      Remember that every encoder is different, and what works for x264 will not apply to other encoders.

      添加 -pix_fmt yuv420p 如果输出不能在像 QuickTime 这样的愚蠢播放器中播放.

      Add -pix_fmt yuv420p if the output does not play in dumb players like QuickTime.

      这篇关于FFMPEG 合理的默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆