ffmpeg constant rate factor for different webm qualities

0

So i came across the following question What is the right way to calculate 1080p 720p 360p 240p quality? But that is for H264 MP4 files.

For MP4 files i set the -crf constant rate factor as 18 for all quality types.

But in webm what should it be set to for the various quality types. 360p 480p 720p 1080p

This is my current webm command line.

"C:/server/ffmpeg/bin/ffmpeg.exe" -y -i Z:/server/websites/ps/public_www/media/com_hwdmediashare/files/84/1a/33/f941f37ad1ee7645bdd1d9773a53f286.mpg -s 528x360   -vcodec libvpx -g 120 -rc_lookahead 16   -qmax 51 -qmin 11  -vb 2M  -b 500k -bufsize 1000k -pass 1 -an -f webm Z:/server/websites/ps/public_www/media/com_hwdmediashare/files/84/1a/33/24bbec26dd3a2dc0809d996ea816bfbe.webm 2>&1

"C:/server/ffmpeg/bin/ffmpeg.exe" -y -i Z:/server/websites/ps/public_www/media/com_hwdmediashare/files/84/1a/33/f941f37ad1ee7645bdd1d9773a53f286.mpg -s 528x360   -vcodec libvpx -g 120 -rc_lookahead 16   -qmax 51 -qmin 11  -vb 2M -maxrate 24M -minrate 100k   -b 500k -bufsize 1000k -pass 2 -acodec libopus -ab 90k -f webm Z:/server/websites/ps/public_www/media/com_hwdmediashare/files/84/1a/33/24bbec26dd3a2dc0809d996ea816bfbe.webm 2>&1

I do not have a crf set but video outputs regardless of size do look slightly blocky and pixelated so i think i should set one.

C0nw0nk

Posted 2015-01-04T11:12:52.487

Reputation: 339

Have you read this? https://trac.ffmpeg.org/wiki/Encode/VP8 — I'm on my mobile only but it should give you a starting point.

– slhck – 2015-01-04T11:24:33.260

Yes i already saw that but based on the different quality types i am not sure what i should use if i should be using the 10 as they recommend in the article or if i should use lower. – C0nw0nk – 2015-01-04T11:25:42.463

Use whatever achieves the level of quality you want or expect. You have to experiment. It all depends on the original videos, their content and what the display context is. – slhck – 2015-01-04T11:27:21.977

So since the crf factor differs from MP4 to Webm what is the equivalent for "-crf 18" what i use on all MP4 files to webm ? – C0nw0nk – 2015-01-04T11:29:54.100

1I would guess around 5–6, but I don't have a lot of experience with VP8. It's been a while since I wrote the article on the wiki. CRF 19 for x264 is very good quality. Just encode a couple of videos and check – slhck – 2015-01-04T11:32:02.873

Thanks slhck i shall set it as "-crf 6" it should hopefully fix the blocky look to my webm videos. – C0nw0nk – 2015-01-04T11:33:24.817

1I posted a proper answer. Let me know what value you chose finally. – slhck – 2015-01-04T16:16:23.213

Answers

2

If the output looks too blocky or pixelated, that's due to a too low bitrate. I see you set 500 kBit/s, but that's much too low for achieving reasonable quality with video at 720p or above.

The VP8 encoding guide lists a few options you have when using the libvpx encoder. I agree with you that using a constant rate factor is the correct approach to achieving the same level of visual quality, regardless of the video resolution.

You were using CRF 18 for the x264 encoder, which is considered very high quality (maybe not visually lossless, but the quality loss should not be perceivable). For libvpx, the CRF range is a little different. 10 is a good default (it would be 23 for x264), and so I'd probably recommend using something like CRF 6–7 for libvpx.

Note that the -qmin parameter must be set equal or lower to the CRF you're choosing. Otherwise it can't encode.

Remember that the resulting bitrate has its upper bound set at whatever you specify with -b:v. Therefore, if your CRF is too low, and your bitrate is set to -b:v 2M, your final bitrate will be 2 MBit/s.

But really, there is nothing better than just trying out different values. It all depends on what your input looks like or what your target application for the videos is. If you're just doing some web streaming, you don't need such high quality video. If you want offline storage, then a lower CRF would of course be better.

slhck

Posted 2015-01-04T11:12:52.487

Reputation: 182 472

I did get the following error adding a crf value to webm's "CQ level 6 must be between minimum and maximum quantizer value" So because i set "-crf 6" and i did not remove "-qmax 51 -qmin 11" from my command line is that making that error i hope the soloution is just to set "-qmin 6". – C0nw0nk – 2015-01-06T10:26:23.913

1Yes that's necessary when using a lower CRF. I will fix my example shortly. – slhck – 2015-01-07T06:43:38.667