Rich Felker wrote:
On Tue, May 10, 2005 at 12:55:44AM -0700, Loren Merritt wrote:
(Warning: anything done by a 1pass encode will be an approximate/soft limit, since you don't know in advance excatly how many bits a given QP will take. So you'll need to fudge the limit a little if you care about strict compliance.)
While true, this isn't an inherent limitation, just a flaw in lavc's rate control engine. It's easy to implement strict limits in 1pass encoding: just repeatedly reencode the frame at different values of qp until you find one that gives the size you want. With binary search it shouldn't even be that slow...
This was the hack I was going to resort to if I couldn't get lavc's RC engine to try to cap the framesize internally. As it stands, though, I'm going to try Loren's suggestion by doing something along the lines of bits= qp2bits(rce, q); ... if (bits > max_frame_size) q = bits2qp(rce, max_frame_size); else // use existing if(max_rate) code in modify_qscale() - assuming that the bits value returned by qp2bits is a guess of the current frame's size at the given picture QP. It's not a complete disaster if the framesize sometimes drifts slightly over the maximum. huge thanks for the advice :) M.