FFMPEG明智的默认值 [英] FFMPEG sensible defaults

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

问题描述

我正在使用ffmpeg使用vfilters像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 作为预设列表,并忽略安慰剂预设,因为它是一个笑话)。

  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 and x264 Encoding Guide
      • FFmpeg and AAC Encoding Guide

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

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