ffmpeg - 如何在不降低质量的情况下应用过滤器 [英] ffmpeg - how to apply filters without losing quality

查看:24
本文介绍了ffmpeg - 如何在不降低质量的情况下应用过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个简单的请求,它有一个输入、输出和两个水印.根据我收集的信息,我无法应用 -codec copy 因为我正在使用过滤器.

Here is a simple request, it has an input, output, and two watermarks. From what I gathered I can't apply -codec copy because I'm using a filter.

ffmpeg -i input.mp4 -i wm-bl.png -i wm-br.png -filter_complex "overlay=x=0:y=H-h,overlay=x=W-w:y=H-h" output.mp4

就水印而言,这可以解决问题,但输出被压缩为原始文件大小的一半.

This does the trick, as far as watermarking is concerned, but the output is compressed into half the original file size.

是否可以在不损失视频质量的情况下添加水印?

Is it possible to watermark without losing video quality?

推荐答案

您必须重新编码才能执行任何过滤

因此,任何在过滤时流复制的尝试都将被忽略.这就是 -codec copy 对你没有任何作用的原因.

You must re-encode to perform any filtering

Therefore any attempt at stream copying while filtering will be ignored. This is why -codec copy does nothing for you.

或者,您可以使用看起来视觉无损"的适当编码设置,但从技术上讲,并不是真正的无损.H.264 示例:

Alternatively you can use proper encoding settings that look "visually lossless", but technically are not truly lossless. Example for H.264:

ffmpeg -i input -codec:v libx264 -crf 18 -preset slow -vf format=yuv420p out.mp4

  • -crf 控制质量:范围是 0-51 的对数刻度,0 是无损,~18 通常被认为是视觉无损的,23 是默认值.

    • -crf controls quality: range is a log scale of 0-51, 0 is lossless, ~18 is often considered visually lossless, and 23 is default.

      -preset 控制编码速度和压缩效率:超快、超快、极快、更快、快速、中等(默认)、慢、慢、非常慢.

      -preset controls encoding speed and therefore compression efficiency: ultrafast, superfast, veryfast, faster, fast, medium (the default), slow, slower, veryslow.

      -vf format=yuv420p 使用大多数播放器所需的兼容色度子采样.

      -vf format=yuv420p uses a compatible chroma subsampling required by most players.

      虽然您必须重新编码以进行过滤,但这并不意味着您必须失去质量.您可以使用无损编码器,例如:

      Although you must re-encode for filtering it does not mean that you have to lose quality. You can use a lossless encoder, such as:

      • -codec:v libx264 -crf 0 -preset veryslow
      • -codec:v ffv1

      输出文件可能很大——通常比输入文件大得多.

      完全避免编码,只需使用 CSS 或 HTML5 视频播放器处理水印.

      Avoid encoding completely and just deal with the watermark with CSS or with your HTML5 video player.

      这篇关于ffmpeg - 如何在不降低质量的情况下应用过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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