Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > New and alternative video codecs

Reply
 
Thread Tools Search this Thread Display Modes
Old 15th September 2015, 20:09   #1  |  Link
orion44
None
 
orion44's Avatar
 
Join Date: Jul 2007
Location: The Background
Posts: 267
When doing 2 pass video encoding with FFmpeg, how to find the optimal bitrate?

When doing 2 pass video encoding with VP8 (libvpx), is there a way to figure out the optimal bitrate,
so I don't have to guess?

Something like a small compression test, or some ffmpeg command,
that will help me determine the appropriate bitrate?

I tried reading the VP8 1st pass stats file in notepad, but it's all garbled.

I'm using Windows 7 with the latest FFmpeg build.
orion44 is offline   Reply With Quote
Old 15th September 2015, 23:52   #2  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 6,835
Sorry, can't really answer that, but I'm curious about:
a. How do you define 'optimal bitrate'?
b. How do you get VP8 to archive an average bitrate that you specify? (last time I checked VP8&VP9 both weren't able to at least nearly hit the average bitrate I specified and thus specifying for example 1000kBit/s and ending up with a 200kBits or 3000kBit/s stream kind of killed the use of 2pass for VP8&VP9)

So that I didn't just post some questions:
In general, you could basically to the same thing all the other compression tests and their users do:
1st do a bunch of encodes and come up with a rule of the thumb about how many bits are needed per pixel so the output will look good for you
2nd do a bunch of encodes and come up with a correlation between the average quantizer used and your pixel goal
3rd encode a portion of your input encode it with a fixed quantizer, this will give you an approximated relation of quantizers and your pixel goal for your current source. Use that approximation and your pixel goal to calculate the average bitrate you want.
4th encode your input with the average bitrate (<- no clue how to do this with vp8 and vp9) you now aim for and assuming your previous approximations and rules are robust enough you archived your goal.
(I'm not aware of any one who did all this and implemented it into some tool)

Quote:
1st pass stats file in notepad, but it's all garbled.
iirc those are embl encoded (vpxenc source code should contain methods to read, write serialize and de-serialize those; haven't seen a tool which allows one to read such a stats file in a decent way)

Quote:
that will help me determine the appropriate bitrate?
encode a lot of content with different bitrates and remember which average bitrate archived a (for you) decent output


=> I had to use VP8, I would probably stick with constant quantizer encoding or (assuming I managed to find a way to produce clips with and average bitrate I specified) I would probably choose a bitrate which is roughly 1.5 times larger than the bitrate I would use for MPEG-4 ASP.
(btw. VP9 would be - a lot - slower encoding wise, normally not get near the bitrate you specified for 2pass encoding, but it would require less bitrate to archive the same quality that VP8 provided, so depending on your goals VP9 might be worth checking it out)

Cu Selur
__________________
Hybrid here in the forum, homepage
Notice: Since email notifications do not work here any more, it might take me quite some time to notice a reply to a thread,..
Selur is offline   Reply With Quote
Old 16th September 2015, 13:03   #3  |  Link
orion44
None
 
orion44's Avatar
 
Join Date: Jul 2007
Location: The Background
Posts: 267
Quote:
Originally Posted by Selur View Post
Sorry, can't really answer that, but I'm curious about:
a. How do you define 'optimal bitrate'?
For me, the optimal bitrate is when the average quantizer value is less than 3.30 for XviD, or around 20 for x264.
It's a shame that VP8 doesn't show any info on the command line about which quantizer values it's using.

For VP8, I'm going to start with low bitrate, and keep increasing it until it looks good to me,
and is comparable to the source video.
Quote:
Originally Posted by Selur View Post
b. How do you get VP8 to archive an average bitrate that you specify? (last time I checked VP8&VP9 both weren't able to at least nearly hit the average bitrate I specified and thus specifying for example 1000kBit/s and ending up with a 200kBits or 3000kBit/s stream kind of killed the use of 2pass for VP8&VP9)
It's easy.

When doing two passes, you only specify the bitrate in the second pass by using the -b:v switch.

You specify the bitrate in bits, not kilobits. So for example, if you want a bitrate of 700 kBit/s,
you specify -b:v 700000.

It is very accurate.

Quote:
Originally Posted by Selur View Post
I would probably choose a bitrate which is roughly 1.5 times larger than the bitrate I would use for MPEG-4 ASP.
No way. That's too much.

I tested both VP8 and Xvid. VP8 requires about 25% smaller bitrate than XviD to achieve better quality.
Here, check it out:

XviD (2 pass, default settings, 900 kbit/s)
VP8 (2 pass, default settings, 700 kbit/s)

Quote:
Originally Posted by Selur View Post
(btw. VP9 would be - a lot - slower encoding wise, normally not get near the bitrate you specified for 2pass encoding, but it would require less bitrate to archive the same quality that VP8 provided, so depending on your goals VP9 might be worth checking it out)
I haven't yet tried it, because I'm happy with VP8 quality, but I'm looking forward to try it in the future.

Last edited by orion44; 16th September 2015 at 20:41.
orion44 is offline   Reply With Quote
Old 18th September 2015, 09:45   #4  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,550
You should probably just run xvid to calculate the bitrate you're looking for. It's almost instantaneous these days, and several old programs even have "compressibility checks" that test a small percentage of video to estimate the total size.

You'd be better off figuring out roughly what crf you're achieving and stick to that, once you've done that a few times. crf is what you really seem to want, given that you "care" about file size but don't have an upper bound aside from xvid's or x264's size, which sounds like not caring about size to me.
foxyshadis is offline   Reply With Quote
Reply

Tags
ffmpeg, vp8

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 17:25.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.