Sane vp9 encoding parameters

762 views
Skip to first unread message

Sagara Wijetunga

unread,
Oct 10, 2014, 10:20:42 AM10/10/14
to webm-d...@webmproject.org
Hi all

I use the latest libvpx-git and the ffmpeg to encode HD video to vp9.


I want to identify sane vp9 encoding parameters to be tweaked without increasing the video bitrate (-b:v) to get higher SSIM values.

The deadline=best increases SSIM without increasing video bitrate, but its way too slow.



I use following preset file values:

cat libvpx-vp9-CQ-good-720p.ffpreset
vcodec=libvpx-vp9

g=120
lag-in-frames=16
deadline=good
cpu-used=0
vprofile=0
qmax=48
qmin=0
crf=8
slices=4
b=2M
tile-columns=2
tile-rows=2
frame-parallel=1


#ignored unless using -pass 2
maxrate=24M
minrate=100k
auto-alt-ref=1
arnr-maxframes=7
arnr-strength=5
arnr-type=centered

1. Is the above "slices" used for vp9 encode?

2. what is "b=2M"? Is it used for vp9 encode?

3. Are the above values used sane? Can it be improved to achieve higher quality without much increasing video bitrate?

4. Are there any other useful parameters to be added to the preset file?

Appreciate your comments in this.

Best regards
Sagara

James Zern

unread,
Oct 10, 2014, 12:02:06 PM10/10/14
to WebM Discussion
Hi,

On Fri, Oct 10, 2014 at 4:19 PM, 'Sagara Wijetunga' via WebM
Discussion <webm-d...@webmproject.org> wrote:
> Hi all
>
> I use the latest libvpx-git and the ffmpeg to encode HD video to vp9.
>
>
> I want to identify sane vp9 encoding parameters to be tweaked without increasing the video bitrate (-b:v) to get higher SSIM values.
>
> The deadline=best increases SSIM without increasing video bitrate, but its way too slow.
>
>
>
> I use following preset file values:
>
> cat libvpx-vp9-CQ-good-720p.ffpreset
> vcodec=libvpx-vp9
>
> g=120
> lag-in-frames=16
> deadline=good
> cpu-used=0

You can probably set this to 1 to speed things up a little.

> vprofile=0
> qmax=48
> qmin=0
> crf=8

You can disable crf to compare the behavior with vbr.

> slices=4
> b=2M
> tile-columns=2
> tile-rows=2

Leave this at 1, there's no benefit in encoding multiple rows.

> frame-parallel=1
>
>
> #ignored unless using -pass 2
> maxrate=24M
> minrate=100k
> auto-alt-ref=1
> arnr-maxframes=7
> arnr-strength=5
> arnr-type=centered
>
> 1. Is the above "slices" used for vp9 encode?
>

No this is for vp8, some terse mapping information is available [1].

> 2. what is "b=2M"? Is it used for vp9 encode?
>

b = bitrate, yes it's used by vp8/vp9.

> 3. Are the above values used sane? Can it be improved to achieve higher quality without much increasing video bitrate?
>

Are you using 2-pass?

> 4. Are there any other useful parameters to be added to the preset file?
>

Noted some above. Other changes will depend on your usage, if you
aren't planning on streaming the video you could enlarge the keyframe
frequency (-g), above it's 120 = 5s @ 24fps.

> Appreciate your comments in this.
>

[1] http://ffmpeg.org/ffmpeg-codecs.html#libvpx

Sagara Wijetunga

unread,
Oct 10, 2014, 1:08:03 PM10/10/14
to webm-d...@webmproject.org
--
You received this message because you are subscribed to the Google Groups "WebM Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webm-discuss...@webmproject.org.
To post to this group, send email to webm-d...@webmproject.org.
Visit this group at http://groups.google.com/a/webmproject.org/group/webm-discuss/.
For more options, visit https://groups.google.com/a/webmproject.org/d/optout.

Sagara Wijetunga

unread,
Oct 10, 2014, 1:36:36 PM10/10/14
to webm-d...@webmproject.org
Hi James, thanks for the reply.


>> 2. what is "b=2M"? Is it used for vp9 encode?

>b = bitrate, yes it's used by vp8/vp9.


I use "-b:v" on the ffmpeg command line. Is the "b=2M" still necessary on the preset file? or is it a fallback rate?


>Are you using 2-pass?


Yes, I use 2-pass encoding.


>Noted some above. Other changes will depend on your usage, if you>aren't planning on streaming the video you could enlarge the >keyframe frequency (-g), above it's 120 = 5s @ 24fps.


I don't intend to stream.

My requirement is to hit avg. SSIM to 0.995 with the minimum bitrate.

Vp8 hits 0.99666 at high bitrate.

Is it wise to reduce qmax below 48?

Btw, sorry for misfiring an earlier email.

Regards
Sagara

James Zern

unread,
Oct 10, 2014, 2:33:01 PM10/10/14
to WebM Discussion
On Fri, Oct 10, 2014 at 7:36 PM, 'Sagara Wijetunga' via WebM
Discussion <webm-d...@webmproject.org> wrote:
> Hi James, thanks for the reply.
>
>
>>> 2. what is "b=2M"? Is it used for vp9 encode?
>
>>b = bitrate, yes it's used by vp8/vp9.
>
>
> I use "-b:v" on the ffmpeg command line. Is the "b=2M" still necessary on the preset file? or is it a fallback rate?
>

Yes this would fallback, the command line settings can be used to
override the preset.

>
>>Are you using 2-pass?
>
>
> Yes, I use 2-pass encoding.
>
>
>>Noted some above. Other changes will depend on your usage, if you>aren't planning on streaming the video you could enlarge the >keyframe frequency (-g), above it's 120 = 5s @ 24fps.
>
>
> I don't intend to stream.
>
> My requirement is to hit avg. SSIM to 0.995 with the minimum bitrate.
>
> Vp8 hits 0.99666 at high bitrate.
>
> Is it wise to reduce qmax below 48?
>

You could try, in general that will hurt the datarate control and
likely result in material that spikes and may overshoot the target
bitrate.

Basil Mohamed Gohar

unread,
Oct 12, 2014, 8:27:19 AM10/12/14
to webm-d...@webmproject.org
If you haven't already tried, also set tune=ssim, if SSIM is your goal.

--
Libre Video
http://librevideo.org

Sagara Wijetunga

unread,
Oct 12, 2014, 10:33:35 AM10/12/14
to webm-d...@webmproject.org
> If you haven't already tried, also set tune=ssim, if SSIM is your goal.

Is the tune implemented in libvpx-git? I get following:


Invalid option or argument: 'tune=ssim', parsed as 'tune' = 'ssim'

Regards
Sagara

Basil Mohamed Gohar

unread,
Oct 13, 2014, 11:01:39 PM10/13/14
to webm-d...@webmproject.org
In vpxenc, you would pass `--tune=ssim`, not sure how to do that via a
library call.

Jianyong Xiao

unread,
Oct 14, 2014, 12:58:49 AM10/14/14
to webm-d...@webmproject.org
Does ffmpeg also supports --tune=ssim parameter as well for vp9?

Basil Mohamed Gohar

unread,
Oct 14, 2014, 6:18:31 PM10/14/14
to webm-d...@webmproject.org

On 2014-10-14 12:58 AM, Jianyong Xiao wrote:

Does ffmpeg also supports --tune=ssim parameter as well for vp9?
I haven't looked into it myself, but if I remember and I get the chance, I'll examine the ffmpeg source and see if that parameter is exposed.

James Zern

unread,
Oct 15, 2014, 10:27:41 AM10/15/14
to WebM Discussion
Hi,

On Wed, Oct 15, 2014 at 12:18 AM, Basil Mohamed Gohar
<basil...@librevideo.org> wrote:
> On 2014-10-14 12:58 AM, Jianyong Xiao wrote:
>
> Does ffmpeg also supports --tune=ssim parameter as well for vp9?
>

This isn't mapped currently. Also note that tune=ssim isn't supported
for vp9 right now either. If you try to pass the option with vpxenc
you'll see:
Failed to control codec: Invalid parameter
Option --tune=ssim is not currently supported in VP9.

Sagara Wijetunga

unread,
Oct 15, 2014, 11:35:27 PM10/15/14
to webm-d...@webmproject.org
>This isn't mapped currently. Also note that tune=ssim isn't supported


>for vp9 right now either. If you try to pass the option with vpxenc

>you'll see:

>Failed to control codec: Invalid parameter

> Option --tune=ssim is not currently supported in VP9.

1) --tune=ssim (ie. tune to ssim)

2) --ssim=0.995 (ie. match to given value)
The 2nd option (propose) --ssim=value would be very useful.

That is, we do not give a bitrate, let the encoder compute the bitrate to match the given ssim.

Regards
Sagara
Reply all
Reply to author
Forward
0 new messages