简体   繁体   English

ffmpeg 质量转换选项(视频压缩)

[英]ffmpeg quality conversion options (video compression)

Can you provide a link, or an explanation, to the -q:v 1 argument that deals with video/image quality, and compression, in ffmpeg.您能否在 ffmpeg 中提供处理视频/图像质量和压缩的-q:v 1参数的链接或解释。

Let me explain...让我解释...

for f in *
   do 
     extension="${f##*.}"
     filename="${f%.*}"
     ffmpeg -i "$f" -q:v 1 "$filename"_lq."$extension"
     rm -f "$f"
   done

The ffmpeg for loop above compresses all images and videos in your working directory, it basically lowers the quality which results in smaller file sizes (the desired outcome).上面的 ffmpeg for循环压缩了您工作目录中的所有图像和视频,它基本上降低了质量,从而导致文件变小(所需的结果)。

I'm most interested in the -q:v 1 argument of this for loop.我对这个for循环的-q:v 1参数最感兴趣。 The 1 in the -q:v 1 argument is what controls the amount of compression.1-q:v 1说法是什么控制的压缩量。 But I can't find any documentation describing how to change this value of 1 , and describing what it does.但是我找不到任何描述如何更改1值并描述它的作用的文档。 Is it a percentage?是百分比吗? Multiplier?乘数? How do I adjust this knob?这个旋钮怎么调? Can/should I use negative values?我可以/应该使用负值吗? Integers only?只有整数? Min/max values?最小值/最大值? etc.等等。

I started with the official documentation but the best I could find was a section on video quality, and the -q flag description is sparse.我从官方文档开始,但我能找到的最好的是关于视频质量的部分,并且-q标志描述很少。

-frames[:stream_specifier] framecount (output,per-stream) -frames[:stream_specifier] 帧数(输出,每个流)
Stop writing to the stream after framecount frames.在帧计数帧后停止写入流。
. .
-q[:stream_specifier] q (output,per-stream) -q[:stream_specifier] q(输出,每个流)

-qscale[:stream_specifier] q (output,per-stream) -qscale[:stream_specifier] q(输出,每个流)
Use fixed quality scale (VBR).使用固定质量标度 (VBR)。 The meaning of q/qscale is codec-dependent. q/qscale 的含义取决于编解码器。 If qscale is used without a stream_specifier then it applies only to the video stream, this is to maintain compatibility with previous behavior and as specifying the same codec specific value to 2 different codecs that is audio and video generally is not what is intended when no stream_specifier is used.如果在没有 stream_specifier 的情况下使用 qscale,则它仅适用于视频流,这是为了保持与先前行为的兼容性,并且因为为音频和视频的 2 个不同编解码器指定相同的编解码器特定值通常不是没有 stream_specifier 时的预期目的用来。

-q:v is probably being ignored -q:v可能被忽略

You are outputting MP4, so it is most likely that you are using the encoder libx264 which outputs H.264 video.您正在输出 MP4,因此很可能您正在使用输出 H.264 视频的编码器 libx264。

-q:v / -qscale:v is ignored by libx264. -q:v / -qscale:v被 libx264 忽略。

The console output even provides a warning about this: -qscale is ignored, -crf is recommended.控制台输出甚至提供了一个警告: -qscale is ignored, -crf is recommended.

For more info on -crf see FFmpeg Wiki: H.264 .有关-crf更多信息,请参阅FFmpeg Wiki:H.264

When can I use -q:v ?我什么时候可以使用-q:v

The MPEG* encoders (mpeg4, mpeg2video, mpeg1video, mjpeg, libxvid, msmpeg4) can use -q:v / -qscale:v . MPEG* 编码器(mpeg4、mpeg2video、mpeg1video、mjpeg、libxvid、msmpeg4)可以使用-q:v / -qscale:v

See How can I extract a good quality JPEG image from a video file with ffmpeg?请参阅如何使用 ffmpeg 从视频文件中提取高质量的 JPEG 图像? for more info on this option.有关此选项的更多信息。

This option is an alias for -qscale:v which might be why you didn't encounter it during your research (eventhough my resultat came first with "ffmpeg q:v" on google).此选项是-qscale:v的别名,这可能是您在研究期间没有遇到它的原因(尽管我的结果首先出现在 google 上的“ffmpeg q:v”)。 This link explains how the qscale option is not a multiplier or a percentage, it's a bitrate mode (so it's to bitrate).链接解释了qscale选项如何不是乘数或百分比,而是比特率模式(因此是比特率)。 For a given encoder, the lower this number the higher the bitrate and quality.对于给定的编码器,此数字越低,比特率和质量就越高。 It usually spans from 1-31 but some encoders can accept a subset of this range.它通常跨越 1-31,但一些编码器可以接受这个范围的一个子集。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM