Can you provide a link, or an explanation, to the -q:v 1
argument that deals with video/image quality, and compression, in ffmpeg.
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).
I'm most interested in the -q:v 1
argument of this for
loop. The 1
in the -q:v 1
argument is what controls the amount of compression. But I can't find any documentation describing how to change this value of 1
, and describing what it does. 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.
-frames[:stream_specifier] framecount (output,per-stream)
Stop writing to the stream after framecount frames.
.
-q[:stream_specifier] q (output,per-stream)
-qscale[:stream_specifier] q (output,per-stream)
Use fixed quality scale (VBR). The meaning of q/qscale is codec-dependent. 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.
-q:v
is probably being ignoredYou are outputting MP4, so it is most likely that you are using the encoder libx264 which outputs H.264 video.
-q:v
/-qscale:v
is ignored by libx264.The console output even provides a warning about this:
-qscale is ignored, -crf is recommended.
For more info on
-crf
see FFmpeg Wiki: H.264.When can I use
-q:v
?The MPEG* encoders (mpeg4, mpeg2video, mpeg1video, mjpeg, libxvid, msmpeg4) can use
-q:v
/-qscale:v
.See How can I extract a good quality JPEG image from a video file with ffmpeg? for more info on this option.