[RFC] ratecontrol buffer size magic
Hi, I stumbed accross a weird behaviour of the CBR ratecontrol lately, basically doing: ffmpeg -i file.mpg -vcodec mpeg2video -minrate 30000k -maxrate 30000k -b 30000k -intra -flags +ildct+low_delay -dc 10 -flags2 +ivlc+non_linear_q -ps 1 -qmin 1 -qmax 12 -top 1 -vglobal 4 -acodec pcm_s16be -f mov -bufsize 1200000 -rc_init_occupancy 1200000 cbr.mov Constraints are so in order to achieve vbv delay as 3600. Now ffmpeg will only give me qp as 24. While tweaking I changed some magic in ratecontrol.c (see patch attached) and now qp have decent/good values. I dig into svn history and found out that r2601 bumped */2 to */3 to improve CBR ratecontrol. Can anyone explain in detail why that magic does improve behaviour ? Can that parameter be user setable ? Or is it really hardcoded everywhere ? Am I doing something terribly wrong ? Thanks for comments. -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA SMARTJOG S.A. http://www.smartjog.com Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA Phone: +33 1 49966312
Hi On Thu, Apr 05, 2007 at 06:51:00PM +0200, Baptiste Coudurier wrote:
Hi,
I stumbed accross a weird behaviour of the CBR ratecontrol lately, basically doing:
ffmpeg -i file.mpg -vcodec mpeg2video -minrate 30000k -maxrate 30000k -b 30000k -intra -flags +ildct+low_delay -dc 10 -flags2 +ivlc+non_linear_q -ps 1 -qmin 1 -qmax 12 -top 1 -vglobal 4 -acodec pcm_s16be -f mov -bufsize 1200000 -rc_init_occupancy 1200000 cbr.mov
Constraints are so in order to achieve vbv delay as 3600. Now ffmpeg will only give me qp as 24. While tweaking I changed some magic in ratecontrol.c (see patch attached) and now qp have decent/good values.
I dig into svn history and found out that r2601 bumped */2 to */3 to improve CBR ratecontrol. Can anyone explain in detail why that magic does improve behaviour ?
yes, your vbv buf size is VERY significantly too small it can barely hold a single frame, increase it by a factor of 100 ... i hope theres no spec which mandates such nonsense parameters ...
Can that parameter be user setable ?
if you make it user settable ... [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I know you won't believe me, but the highest form of Human Excellence is to question oneself and others. -- Socrates
Michael Niedermayer wrote:
Hi
On Thu, Apr 05, 2007 at 06:51:00PM +0200, Baptiste Coudurier wrote:
Hi,
I stumbed accross a weird behaviour of the CBR ratecontrol lately, basically doing:
ffmpeg -i file.mpg -vcodec mpeg2video -minrate 30000k -maxrate 30000k -b 30000k -intra -flags +ildct+low_delay -dc 10 -flags2 +ivlc+non_linear_q -ps 1 -qmin 1 -qmax 12 -top 1 -vglobal 4 -acodec pcm_s16be -f mov -bufsize 1200000 -rc_init_occupancy 1200000 cbr.mov
Constraints are so in order to achieve vbv delay as 3600. Now ffmpeg will only give me qp as 24. While tweaking I changed some magic in ratecontrol.c (see patch attached) and now qp have decent/good values.
I dig into svn history and found out that r2601 bumped */2 to */3 to improve CBR ratecontrol. Can anyone explain in detail why that magic does improve behaviour ?
yes, your vbv buf size is VERY significantly too small it can barely hold a single frame, increase it by a factor of 100 ...
yes, point is to only have 1 frame at 25 fps in vbv I guess, for NTSC it is 3003. I wish I could increase it, you get very good encoding even with vbv 36000.
i hope theres no spec which mandates such nonsense parameters ...
there is unfortunately... D10 ;)
Can that parameter be user setable ?
if you make it user settable ...
ok. -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA SMARTJOG S.A. http://www.smartjog.com Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA Phone: +33 1 49966312
Hi Michael Niedermayer wrote:
Hi
On Thu, Apr 05, 2007 at 06:51:00PM +0200, Baptiste Coudurier wrote:
Hi,
I stumbed accross a weird behaviour of the CBR ratecontrol lately, basically doing:
ffmpeg -i file.mpg -vcodec mpeg2video -minrate 30000k -maxrate 30000k -b 30000k -intra -flags +ildct+low_delay -dc 10 -flags2 +ivlc+non_linear_q -ps 1 -qmin 1 -qmax 12 -top 1 -vglobal 4 -acodec pcm_s16be -f mov -bufsize 1200000 -rc_init_occupancy 1200000 cbr.mov
Constraints are so in order to achieve vbv delay as 3600. Now ffmpeg will only give me qp as 24. While tweaking I changed some magic in ratecontrol.c (see patch attached) and now qp have decent/good values.
I dig into svn history and found out that r2601 bumped */2 to */3 to improve CBR ratecontrol. Can anyone explain in detail why that magic does improve behaviour ?
yes, your vbv buf size is VERY significantly too small it can barely hold a single frame, increase it by a factor of 100 ...
i hope theres no spec which mandates such nonsense parameters ...
Can that parameter be user setable ?
if you make it user settable ...
Is something like that ok ? -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA SMARTJOG S.A. http://www.smartjog.com Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA Phone: +33 1 49966312
Hi On Wed, Apr 11, 2007 at 01:47:55PM +0200, Baptiste Coudurier wrote:
Hi
Michael Niedermayer wrote:
Hi
On Thu, Apr 05, 2007 at 06:51:00PM +0200, Baptiste Coudurier wrote:
Hi,
I stumbed accross a weird behaviour of the CBR ratecontrol lately, basically doing:
ffmpeg -i file.mpg -vcodec mpeg2video -minrate 30000k -maxrate 30000k -b 30000k -intra -flags +ildct+low_delay -dc 10 -flags2 +ivlc+non_linear_q -ps 1 -qmin 1 -qmax 12 -top 1 -vglobal 4 -acodec pcm_s16be -f mov -bufsize 1200000 -rc_init_occupancy 1200000 cbr.mov
Constraints are so in order to achieve vbv delay as 3600. Now ffmpeg will only give me qp as 24. While tweaking I changed some magic in ratecontrol.c (see patch attached) and now qp have decent/good values.
I dig into svn history and found out that r2601 bumped */2 to */3 to improve CBR ratecontrol. Can anyone explain in detail why that magic does improve behaviour ?
yes, your vbv buf size is VERY significantly too small it can barely hold a single frame, increase it by a factor of 100 ...
i hope theres no spec which mandates such nonsense parameters ...
Can that parameter be user setable ?
if you make it user settable ...
Is something like that ok ?
yes except that name of the variable and the comment [...]
+ /** + * Ratecontrol buffer space available coefficient used when + * encoding with a buffer size. + * - encoding: Set by user. + * - decoding: unused + */ + float rc_buffer_avail_coeff; } AVCodecContext;
[...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB There will always be a question for which you do not know the correct awnser.
Hi Michael Niedermayer wrote:
Hi
On Wed, Apr 11, 2007 at 01:47:55PM +0200, Baptiste Coudurier wrote:
Hi
Michael Niedermayer wrote:
Hi
On Thu, Apr 05, 2007 at 06:51:00PM +0200, Baptiste Coudurier wrote:
Hi,
I stumbed accross a weird behaviour of the CBR ratecontrol lately, basically doing:
ffmpeg -i file.mpg -vcodec mpeg2video -minrate 30000k -maxrate 30000k -b 30000k -intra -flags +ildct+low_delay -dc 10 -flags2 +ivlc+non_linear_q -ps 1 -qmin 1 -qmax 12 -top 1 -vglobal 4 -acodec pcm_s16be -f mov -bufsize 1200000 -rc_init_occupancy 1200000 cbr.mov
Constraints are so in order to achieve vbv delay as 3600. Now ffmpeg will only give me qp as 24. While tweaking I changed some magic in ratecontrol.c (see patch attached) and now qp have decent/good values.
I dig into svn history and found out that r2601 bumped */2 to */3 to improve CBR ratecontrol. Can anyone explain in detail why that magic does improve behaviour ? yes, your vbv buf size is VERY significantly too small it can barely hold a single frame, increase it by a factor of 100 ...
i hope theres no spec which mandates such nonsense parameters ...
Can that parameter be user setable ? if you make it user settable ... Is something like that ok ?
yes except that name of the variable and the comment
+ + /** + * Ratecontrol available buffer space coefficient applied when choosing qp. + * - encoding: Set by user. + * - decoding: unused + */ + float rc_buffer_space_avail_coeff; or shorter rc_buffer_space_coeff ? rc_buf_space_coeff for AVOption ? Is it better ? Do you have a better name ? -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA SMARTJOG S.A. http://www.smartjog.com Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA Phone: +33 1 49966312
Hi On Thu, Apr 12, 2007 at 11:07:10AM +0200, Baptiste Coudurier wrote:
Hi
Michael Niedermayer wrote:
Hi
On Wed, Apr 11, 2007 at 01:47:55PM +0200, Baptiste Coudurier wrote:
Hi
Michael Niedermayer wrote:
Hi
On Thu, Apr 05, 2007 at 06:51:00PM +0200, Baptiste Coudurier wrote:
Hi,
I stumbed accross a weird behaviour of the CBR ratecontrol lately, basically doing:
ffmpeg -i file.mpg -vcodec mpeg2video -minrate 30000k -maxrate 30000k -b 30000k -intra -flags +ildct+low_delay -dc 10 -flags2 +ivlc+non_linear_q -ps 1 -qmin 1 -qmax 12 -top 1 -vglobal 4 -acodec pcm_s16be -f mov -bufsize 1200000 -rc_init_occupancy 1200000 cbr.mov
Constraints are so in order to achieve vbv delay as 3600. Now ffmpeg will only give me qp as 24. While tweaking I changed some magic in ratecontrol.c (see patch attached) and now qp have decent/good values.
I dig into svn history and found out that r2601 bumped */2 to */3 to improve CBR ratecontrol. Can anyone explain in detail why that magic does improve behaviour ? yes, your vbv buf size is VERY significantly too small it can barely hold a single frame, increase it by a factor of 100 ...
i hope theres no spec which mandates such nonsense parameters ...
Can that parameter be user setable ? if you make it user settable ... Is something like that ok ?
yes except that name of the variable and the comment
+ + /** + * Ratecontrol available buffer space coefficient applied when choosing qp.
does anyone understand what this variable does based on this description? no? if no then patch rejected [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Opposition brings concord. Out of discord comes the fairest harmony. -- Heraclitus
Michael Niedermayer wrote:
Hi
On Thu, Apr 12, 2007 at 11:07:10AM +0200, Baptiste Coudurier wrote:
Hi
Hi
On Wed, Apr 11, 2007 at 01:47:55PM +0200, Baptiste Coudurier wrote:
Hi
Michael Niedermayer wrote:
Hi
On Thu, Apr 05, 2007 at 06:51:00PM +0200, Baptiste Coudurier wrote:
Hi,
I stumbed accross a weird behaviour of the CBR ratecontrol lately, basically doing:
ffmpeg -i file.mpg -vcodec mpeg2video -minrate 30000k -maxrate 30000k -b 30000k -intra -flags +ildct+low_delay -dc 10 -flags2 +ivlc+non_linear_q -ps 1 -qmin 1 -qmax 12 -top 1 -vglobal 4 -acodec pcm_s16be -f mov -bufsize 1200000 -rc_init_occupancy 1200000 cbr.mov
Constraints are so in order to achieve vbv delay as 3600. Now ffmpeg will only give me qp as 24. While tweaking I changed some magic in ratecontrol.c (see patch attached) and now qp have decent/good values.
I dig into svn history and found out that r2601 bumped */2 to */3 to improve CBR ratecontrol. Can anyone explain in detail why that magic does improve behaviour ? yes, your vbv buf size is VERY significantly too small it can barely hold a single frame, increase it by a factor of 100 ...
i hope theres no spec which mandates such nonsense parameters ...
Can that parameter be user setable ? if you make it user settable ... Is something like that ok ? yes except that name of the variable and the comment
Michael Niedermayer wrote: + + /** + * Ratecontrol available buffer space coefficient applied when choosing qp.
does anyone understand what this variable does based on this description? no? if no then patch rejected
Humm ok another try: /** * Coefficient applied to buffer space, by ratecontrol, * for limiting QP (bits2qp) when encoding with a buffer size. * - encoding: Set by user. * - decoding: unused */ float rc_buffer_space_to_qp_coeff; {"rc_buf_space_to_qp_coeff", "ratecontrol buffer space coefficient for limiting qp", OFFSET(rc_avail_buffer_space_coeff), FF_OPT_TYPE_FLOAT, 3.0, FLT_MIN, FLT_MAX, V|E}, -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA SMARTJOG S.A. http://www.smartjog.com Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA Phone: +33 1 49966312
Hi On Wed, Apr 25, 2007 at 12:21:52PM +0200, Baptiste Coudurier wrote:
Michael Niedermayer wrote:
Hi
On Thu, Apr 12, 2007 at 11:07:10AM +0200, Baptiste Coudurier wrote:
Hi
Hi
On Wed, Apr 11, 2007 at 01:47:55PM +0200, Baptiste Coudurier wrote:
Hi
Michael Niedermayer wrote:
Hi
On Thu, Apr 05, 2007 at 06:51:00PM +0200, Baptiste Coudurier wrote: > Hi, > > I stumbed accross a weird behaviour of the CBR ratecontrol lately, > basically doing: > > ffmpeg -i file.mpg -vcodec mpeg2video -minrate 30000k -maxrate 30000k > -b 30000k -intra -flags +ildct+low_delay -dc 10 -flags2 > +ivlc+non_linear_q -ps 1 -qmin 1 -qmax 12 -top 1 -vglobal 4 -acodec > pcm_s16be -f mov -bufsize 1200000 -rc_init_occupancy 1200000 cbr.mov > > Constraints are so in order to achieve vbv delay as 3600. > Now ffmpeg will only give me qp as 24. While tweaking I changed some > magic in ratecontrol.c (see patch attached) and now qp have decent/good > values. > > I dig into svn history and found out that r2601 bumped */2 to */3 to > improve CBR ratecontrol. Can anyone explain in detail why that magic > does improve behaviour ? yes, your vbv buf size is VERY significantly too small it can barely hold a single frame, increase it by a factor of 100 ...
i hope theres no spec which mandates such nonsense parameters ...
> Can that parameter be user setable ? if you make it user settable ... Is something like that ok ? yes except that name of the variable and the comment
Michael Niedermayer wrote: + + /** + * Ratecontrol available buffer space coefficient applied when choosing qp.
does anyone understand what this variable does based on this description? no? if no then patch rejected
Humm ok another try:
/** * Coefficient applied to buffer space, by ratecontrol, * for limiting QP (bits2qp) when encoding with a buffer size. * - encoding: Set by user. * - decoding: unused */ float rc_buffer_space_to_qp_coeff;
hmm its better but still the description says therese that parameter which is a coefficient and that is applied to the buffer space, whats still unclear * buffer? -> vbv buffer * buffer space? is that the size of the whole buffer? of the free space left? * applied? if id say ill apply a coeffificint to a number 95% of the math people would lynch me, its scaled or multiplied or something like that or if its a more complex operation then that should also be said more clearly * also what is the now changed "buffer size" used for? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB There will always be a question for which you do not know the correct awnser.
Hi Michael Niedermayer wrote:
Hi
On Wed, Apr 25, 2007 at 12:21:52PM +0200, Baptiste Coudurier wrote:
Michael Niedermayer wrote:
Hi
On Thu, Apr 12, 2007 at 11:07:10AM +0200, Baptiste Coudurier wrote:
Hi
Hi
On Wed, Apr 11, 2007 at 01:47:55PM +0200, Baptiste Coudurier wrote:
Hi
Michael Niedermayer wrote: > Hi > > On Thu, Apr 05, 2007 at 06:51:00PM +0200, Baptiste Coudurier wrote: >> Hi, >> >> I stumbed accross a weird behaviour of the CBR ratecontrol lately, >> basically doing: >> >> ffmpeg -i file.mpg -vcodec mpeg2video -minrate 30000k -maxrate 30000k >> -b 30000k -intra -flags +ildct+low_delay -dc 10 -flags2 >> +ivlc+non_linear_q -ps 1 -qmin 1 -qmax 12 -top 1 -vglobal 4 -acodec >> pcm_s16be -f mov -bufsize 1200000 -rc_init_occupancy 1200000 cbr.mov >> >> Constraints are so in order to achieve vbv delay as 3600. >> Now ffmpeg will only give me qp as 24. While tweaking I changed some >> magic in ratecontrol.c (see patch attached) and now qp have decent/good >> values. >> >> I dig into svn history and found out that r2601 bumped */2 to */3 to >> improve CBR ratecontrol. Can anyone explain in detail why that magic >> does improve behaviour ? > yes, your vbv buf size is VERY significantly too small it can barely > hold a single frame, increase it by a factor of 100 ... > > i hope theres no spec which mandates such nonsense parameters ... > > >> Can that parameter be user setable ? > if you make it user settable ... Is something like that ok ? yes except that name of the variable and the comment
Michael Niedermayer wrote: + + /** + * Ratecontrol available buffer space coefficient applied when choosing qp. does anyone understand what this variable does based on this description? no? if no then patch rejected Humm ok another try:
/** * Coefficient applied to buffer space, by ratecontrol, * for limiting QP (bits2qp) when encoding with a buffer size. * - encoding: Set by user. * - decoding: unused */ float rc_buffer_space_to_qp_coeff;
hmm its better but still the description says therese that parameter which is a coefficient and that is applied to the buffer space, whats still unclear * buffer? -> vbv buffer * buffer space? is that the size of the whole buffer? of the free space left? * applied? if id say ill apply a coeffificint to a number 95% of the math people would lynch me, its scaled or multiplied or something like that or if its a more complex operation then that should also be said more clearly * also what is the now changed "buffer size" used for?
Another try: /** * Ratecontrol factor applied to vbv buffer free space when limiting QP (bits2qp). * With a maximum rate: free space / factor; * With a minimum rate: free space * factor; * - encoding: Set by user. * - decoding: unused */ float rc_vbv_to_qp_factor; {"rc_vbv_to_qp_factor", "ratecontrol vbv buffer free space to qp factor", OFFSET(rc_vbv_buf_free_space_to_qp_factor), FF_OPT_TYPE_FLOAT, 3.0, FLT_MIN, FLT_MAX, V|E}, Im trying to keep name somewhat short. -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA SMARTJOG S.A. http://www.smartjog.com Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA Phone: +33 1 49966312
Hi On Tue, Sep 25, 2007 at 12:00:02PM +0200, Baptiste Coudurier wrote:
Hi
Michael Niedermayer wrote:
Hi
On Wed, Apr 25, 2007 at 12:21:52PM +0200, Baptiste Coudurier wrote:
Michael Niedermayer wrote:
Hi
On Thu, Apr 12, 2007 at 11:07:10AM +0200, Baptiste Coudurier wrote:
Hi
Hi
On Wed, Apr 11, 2007 at 01:47:55PM +0200, Baptiste Coudurier wrote: > Hi > > Michael Niedermayer wrote: >> Hi >> >> On Thu, Apr 05, 2007 at 06:51:00PM +0200, Baptiste Coudurier wrote: >>> Hi, >>> >>> I stumbed accross a weird behaviour of the CBR ratecontrol lately, >>> basically doing: >>> >>> ffmpeg -i file.mpg -vcodec mpeg2video -minrate 30000k -maxrate 30000k >>> -b 30000k -intra -flags +ildct+low_delay -dc 10 -flags2 >>> +ivlc+non_linear_q -ps 1 -qmin 1 -qmax 12 -top 1 -vglobal 4 -acodec >>> pcm_s16be -f mov -bufsize 1200000 -rc_init_occupancy 1200000 cbr.mov >>> >>> Constraints are so in order to achieve vbv delay as 3600. >>> Now ffmpeg will only give me qp as 24. While tweaking I changed some >>> magic in ratecontrol.c (see patch attached) and now qp have decent/good >>> values. >>> >>> I dig into svn history and found out that r2601 bumped */2 to */3 to >>> improve CBR ratecontrol. Can anyone explain in detail why that magic >>> does improve behaviour ? >> yes, your vbv buf size is VERY significantly too small it can barely >> hold a single frame, increase it by a factor of 100 ... >> >> i hope theres no spec which mandates such nonsense parameters ... >> >> >>> Can that parameter be user setable ? >> if you make it user settable ... > Is something like that ok ? yes except that name of the variable and the comment
Michael Niedermayer wrote: + + /** + * Ratecontrol available buffer space coefficient applied when choosing qp. does anyone understand what this variable does based on this description? no? if no then patch rejected Humm ok another try:
/** * Coefficient applied to buffer space, by ratecontrol, * for limiting QP (bits2qp) when encoding with a buffer size. * - encoding: Set by user. * - decoding: unused */ float rc_buffer_space_to_qp_coeff;
hmm its better but still the description says therese that parameter which is a coefficient and that is applied to the buffer space, whats still unclear * buffer? -> vbv buffer * buffer space? is that the size of the whole buffer? of the free space left? * applied? if id say ill apply a coeffificint to a number 95% of the math people would lynch me, its scaled or multiplied or something like that or if its a more complex operation then that should also be said more clearly * also what is the now changed "buffer size" used for?
Another try:
/** * Ratecontrol factor applied to vbv buffer free space when limiting QP (bits2qp). * With a maximum rate: free space / factor; * With a minimum rate: free space * factor; * - encoding: Set by user. * - decoding: unused */ float rc_vbv_to_qp_factor;
{"rc_vbv_to_qp_factor", "ratecontrol vbv buffer free space to qp factor", OFFSET(rc_vbv_buf_free_space_to_qp_factor), FF_OPT_TYPE_FLOAT, 3.0, FLT_MIN, FLT_MAX, V|E},
Im trying to keep name somewhat short.
please split this variable in 2 2 good names would be: rc_max_available_vbv_use (default 1.0/3) that is attempt use at maximum 1/3 of what we can use without a underflow rc_min_vbv_overflow_use (default 3) that attempt to use at least 3 times the amount we must use to prevent a vbv overflow [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I know you won't believe me, but the highest form of Human Excellence is to question oneself and others. -- Socrates
Hi Michael, Michael Niedermayer wrote:
Hi
On Tue, Sep 25, 2007 at 12:00:02PM +0200, Baptiste Coudurier wrote:
Hi
Michael Niedermayer wrote:
Hi
Michael Niedermayer wrote:
Hi
On Thu, Apr 12, 2007 at 11:07:10AM +0200, Baptiste Coudurier wrote:
Hi
Michael Niedermayer wrote: > Hi > > On Wed, Apr 11, 2007 at 01:47:55PM +0200, Baptiste Coudurier wrote: >> Hi >> >> Michael Niedermayer wrote: >>> Hi >>> >>> On Thu, Apr 05, 2007 at 06:51:00PM +0200, Baptiste Coudurier wrote: >>>> Hi, >>>> >>>> I stumbed accross a weird behaviour of the CBR ratecontrol lately, >>>> basically doing: >>>> >>>> ffmpeg -i file.mpg -vcodec mpeg2video -minrate 30000k -maxrate 30000k >>>> -b 30000k -intra -flags +ildct+low_delay -dc 10 -flags2 >>>> +ivlc+non_linear_q -ps 1 -qmin 1 -qmax 12 -top 1 -vglobal 4 -acodec >>>> pcm_s16be -f mov -bufsize 1200000 -rc_init_occupancy 1200000 cbr.mov >>>> >>>> Constraints are so in order to achieve vbv delay as 3600. >>>> Now ffmpeg will only give me qp as 24. While tweaking I changed some >>>> magic in ratecontrol.c (see patch attached) and now qp have decent/good >>>> values. >>>> >>>> I dig into svn history and found out that r2601 bumped */2 to */3 to >>>> improve CBR ratecontrol. Can anyone explain in detail why that magic >>>> does improve behaviour ? >>> yes, your vbv buf size is VERY significantly too small it can barely >>> hold a single frame, increase it by a factor of 100 ... >>> >>> i hope theres no spec which mandates such nonsense parameters ... >>> >>> >>>> Can that parameter be user setable ? >>> if you make it user settable ... >> Is something like that ok ? > yes except that name of the variable and the comment + + /** + * Ratecontrol available buffer space coefficient applied when choosing qp. does anyone understand what this variable does based on this description? no? if no then patch rejected Humm ok another try:
/** * Coefficient applied to buffer space, by ratecontrol, * for limiting QP (bits2qp) when encoding with a buffer size. * - encoding: Set by user. * - decoding: unused */ float rc_buffer_space_to_qp_coeff; hmm its better but still
On Wed, Apr 25, 2007 at 12:21:52PM +0200, Baptiste Coudurier wrote: the description says therese that parameter which is a coefficient and that is applied to the buffer space, whats still unclear * buffer? -> vbv buffer * buffer space? is that the size of the whole buffer? of the free space left? * applied? if id say ill apply a coeffificint to a number 95% of the math people would lynch me, its scaled or multiplied or something like that or if its a more complex operation then that should also be said more clearly * also what is the now changed "buffer size" used for?
Another try:
/** * Ratecontrol factor applied to vbv buffer free space when limiting QP (bits2qp). * With a maximum rate: free space / factor; * With a minimum rate: free space * factor; * - encoding: Set by user. * - decoding: unused */ float rc_vbv_to_qp_factor;
{"rc_vbv_to_qp_factor", "ratecontrol vbv buffer free space to qp factor", OFFSET(rc_vbv_buf_free_space_to_qp_factor), FF_OPT_TYPE_FLOAT, 3.0, FLT_MIN, FLT_MAX, V|E},
Im trying to keep name somewhat short.
please split this variable in 2 2 good names would be:
rc_max_available_vbv_use (default 1.0/3) that is attempt use at maximum 1/3 of what we can use without a underflow
rc_min_vbv_overflow_use (default 3) that attempt to use at least 3 times the amount we must use to prevent a vbv overflow
Patch attached. -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA SMARTJOG S.A. http://www.smartjog.com Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA Phone: +33 1 49966312
Hi On Tue, Oct 16, 2007 at 12:17:26PM +0200, Baptiste Coudurier wrote:
Hi Michael,
Michael Niedermayer wrote:
Hi
On Tue, Sep 25, 2007 at 12:00:02PM +0200, Baptiste Coudurier wrote:
Hi
Michael Niedermayer wrote:
Hi
Michael Niedermayer wrote:
Hi
On Thu, Apr 12, 2007 at 11:07:10AM +0200, Baptiste Coudurier wrote: > Hi > > Michael Niedermayer wrote: >> Hi >> >> On Wed, Apr 11, 2007 at 01:47:55PM +0200, Baptiste Coudurier wrote: >>> Hi >>> >>> Michael Niedermayer wrote: >>>> Hi >>>> >>>> On Thu, Apr 05, 2007 at 06:51:00PM +0200, Baptiste Coudurier wrote: >>>>> Hi, >>>>> >>>>> I stumbed accross a weird behaviour of the CBR ratecontrol lately, >>>>> basically doing: >>>>> >>>>> ffmpeg -i file.mpg -vcodec mpeg2video -minrate 30000k -maxrate 30000k >>>>> -b 30000k -intra -flags +ildct+low_delay -dc 10 -flags2 >>>>> +ivlc+non_linear_q -ps 1 -qmin 1 -qmax 12 -top 1 -vglobal 4 -acodec >>>>> pcm_s16be -f mov -bufsize 1200000 -rc_init_occupancy 1200000 cbr.mov >>>>> >>>>> Constraints are so in order to achieve vbv delay as 3600. >>>>> Now ffmpeg will only give me qp as 24. While tweaking I changed some >>>>> magic in ratecontrol.c (see patch attached) and now qp have decent/good >>>>> values. >>>>> >>>>> I dig into svn history and found out that r2601 bumped */2 to */3 to >>>>> improve CBR ratecontrol. Can anyone explain in detail why that magic >>>>> does improve behaviour ? >>>> yes, your vbv buf size is VERY significantly too small it can barely >>>> hold a single frame, increase it by a factor of 100 ... >>>> >>>> i hope theres no spec which mandates such nonsense parameters ... >>>> >>>> >>>>> Can that parameter be user setable ? >>>> if you make it user settable ... >>> Is something like that ok ? >> yes except that name of the variable and the comment > + > + /** > + * Ratecontrol available buffer space coefficient applied when > choosing qp. does anyone understand what this variable does based on this description? no? if no then patch rejected Humm ok another try:
/** * Coefficient applied to buffer space, by ratecontrol, * for limiting QP (bits2qp) when encoding with a buffer size. * - encoding: Set by user. * - decoding: unused */ float rc_buffer_space_to_qp_coeff; hmm its better but still
On Wed, Apr 25, 2007 at 12:21:52PM +0200, Baptiste Coudurier wrote: the description says therese that parameter which is a coefficient and that is applied to the buffer space, whats still unclear * buffer? -> vbv buffer * buffer space? is that the size of the whole buffer? of the free space left? * applied? if id say ill apply a coeffificint to a number 95% of the math people would lynch me, its scaled or multiplied or something like that or if its a more complex operation then that should also be said more clearly * also what is the now changed "buffer size" used for?
Another try:
/** * Ratecontrol factor applied to vbv buffer free space when limiting QP (bits2qp). * With a maximum rate: free space / factor; * With a minimum rate: free space * factor; * - encoding: Set by user. * - decoding: unused */ float rc_vbv_to_qp_factor;
{"rc_vbv_to_qp_factor", "ratecontrol vbv buffer free space to qp factor", OFFSET(rc_vbv_buf_free_space_to_qp_factor), FF_OPT_TYPE_FLOAT, 3.0, FLT_MIN, FLT_MAX, V|E},
Im trying to keep name somewhat short.
please split this variable in 2 2 good names would be:
rc_max_available_vbv_use (default 1.0/3) that is attempt use at maximum 1/3 of what we can use without a underflow
rc_min_vbv_overflow_use (default 3) that attempt to use at least 3 times the amount we must use to prevent a vbv overflow
Patch attached.
ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Democracy is the form of government in which you can choose your dictator
On date Tuesday 2007-10-16 22:20:17 +0200, Michael Niedermayer encoded:
Hi
On Tue, Oct 16, 2007 at 12:17:26PM +0200, Baptiste Coudurier wrote:
Hi Michael,
Michael Niedermayer wrote:
Hi
On Tue, Sep 25, 2007 at 12:00:02PM +0200, Baptiste Coudurier wrote: [...]
Another try:
/** * Ratecontrol factor applied to vbv buffer free space when limiting QP (bits2qp). * With a maximum rate: free space / factor; * With a minimum rate: free space * factor; * - encoding: Set by user. * - decoding: unused */ float rc_vbv_to_qp_factor;
{"rc_vbv_to_qp_factor", "ratecontrol vbv buffer free space to qp factor", OFFSET(rc_vbv_buf_free_space_to_qp_factor), FF_OPT_TYPE_FLOAT, 3.0, FLT_MIN, FLT_MAX, V|E},
Im trying to keep name somewhat short.
please split this variable in 2 2 good names would be:
rc_max_available_vbv_use (default 1.0/3) that is attempt use at maximum 1/3 of what we can use without a underflow
rc_min_vbv_overflow_use (default 3) that attempt to use at least 3 times the amount we must use to prevent a vbv overflow
Patch attached.
ok
I'm interested in this patch too. Since Michael OKed it could someone apply it? I diffed the previous patch against the latest SVN, in order to get a clean patch. Best regards. -- Stefano Sabatini Linux user number 337176 (see http://counter.li.org)
On date Monday 2007-11-19 11:09:34 +0100, Stefano Sabatini encoded:
On date Tuesday 2007-10-16 22:20:17 +0200, Michael Niedermayer encoded:
Hi
On Tue, Oct 16, 2007 at 12:17:26PM +0200, Baptiste Coudurier wrote:
Hi Michael,
Michael Niedermayer wrote:
Hi
On Tue, Sep 25, 2007 at 12:00:02PM +0200, Baptiste Coudurier wrote: [...]
Another try:
/** * Ratecontrol factor applied to vbv buffer free space when limiting QP (bits2qp). * With a maximum rate: free space / factor; * With a minimum rate: free space * factor; * - encoding: Set by user. * - decoding: unused */ float rc_vbv_to_qp_factor;
{"rc_vbv_to_qp_factor", "ratecontrol vbv buffer free space to qp factor", OFFSET(rc_vbv_buf_free_space_to_qp_factor), FF_OPT_TYPE_FLOAT, 3.0, FLT_MIN, FLT_MAX, V|E},
Im trying to keep name somewhat short.
please split this variable in 2 2 good names would be:
rc_max_available_vbv_use (default 1.0/3) that is attempt use at maximum 1/3 of what we can use without a underflow
rc_min_vbv_overflow_use (default 3) that attempt to use at least 3 times the amount we must use to prevent a vbv overflow
Patch attached.
ok
I'm interested in this patch too. Since Michael OKed it could someone apply it?
I diffed the previous patch against the latest SVN, in order to get a clean patch.
Ping + patch diffed against latest SVN. I also added a bump to libavcodec minor. Regards. -- Stefano Sabatini Linux user number 337176 (see http://counter.li.org)
On Wed, Dec 05, 2007 at 04:46:14PM +0100, Stefano Sabatini wrote:
On date Monday 2007-11-19 11:09:34 +0100, Stefano Sabatini encoded:
On date Tuesday 2007-10-16 22:20:17 +0200, Michael Niedermayer encoded:
Hi
On Tue, Oct 16, 2007 at 12:17:26PM +0200, Baptiste Coudurier wrote:
Hi Michael,
Michael Niedermayer wrote:
Hi
On Tue, Sep 25, 2007 at 12:00:02PM +0200, Baptiste Coudurier wrote: [...]
Another try:
/** * Ratecontrol factor applied to vbv buffer free space when limiting QP (bits2qp). * With a maximum rate: free space / factor; * With a minimum rate: free space * factor; * - encoding: Set by user. * - decoding: unused */ float rc_vbv_to_qp_factor;
{"rc_vbv_to_qp_factor", "ratecontrol vbv buffer free space to qp factor", OFFSET(rc_vbv_buf_free_space_to_qp_factor), FF_OPT_TYPE_FLOAT, 3.0, FLT_MIN, FLT_MAX, V|E},
Im trying to keep name somewhat short.
please split this variable in 2 2 good names would be:
rc_max_available_vbv_use (default 1.0/3) that is attempt use at maximum 1/3 of what we can use without a underflow
rc_min_vbv_overflow_use (default 3) that attempt to use at least 3 times the amount we must use to prevent a vbv overflow
Patch attached.
ok
I'm interested in this patch too. Since Michael OKed it could someone apply it?
I diffed the previous patch against the latest SVN, in order to get a clean patch.
Ping + patch diffed against latest SVN. I also added a bump to libavcodec minor.
Regards. -- Stefano Sabatini Linux user number 337176 (see http://counter.li.org)
Is there any reason why this one wasnt applied? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I am the wisest man alive, for I know one thing, and that is that I know nothing. -- Socrates
On date Wednesday 2008-11-26 01:33:33 +0100, Michael Niedermayer encoded:
On Wed, Dec 05, 2007 at 04:46:14PM +0100, Stefano Sabatini wrote:
On date Monday 2007-11-19 11:09:34 +0100, Stefano Sabatini encoded:
On date Tuesday 2007-10-16 22:20:17 +0200, Michael Niedermayer encoded:
On Tue, Oct 16, 2007 at 12:17:26PM +0200, Baptiste Coudurier wrote: [...]
Patch attached.
ok
I'm interested in this patch too. Since Michael OKed it could someone apply it?
I diffed the previous patch against the latest SVN, in order to get a clean patch.
Ping + patch diffed against latest SVN. I also added a bump to libavcodec minor. [...] Is there any reason why this one wasnt applied?
I don't know, but here it is an updated patch. Regards. -- FFmpeg = Funny and Fiendish Mind-dumbing Pitiless Ecletic Gymnast
On Thu, Nov 27, 2008 at 11:50:28PM +0100, Stefano Sabatini wrote:
On date Wednesday 2008-11-26 01:33:33 +0100, Michael Niedermayer encoded:
On Wed, Dec 05, 2007 at 04:46:14PM +0100, Stefano Sabatini wrote:
On date Monday 2007-11-19 11:09:34 +0100, Stefano Sabatini encoded:
On date Tuesday 2007-10-16 22:20:17 +0200, Michael Niedermayer encoded:
On Tue, Oct 16, 2007 at 12:17:26PM +0200, Baptiste Coudurier wrote: [...]
Patch attached.
ok
I'm interested in this patch too. Since Michael OKed it could someone apply it?
I diffed the previous patch against the latest SVN, in order to get a clean patch.
Ping + patch diffed against latest SVN. I also added a bump to libavcodec minor. [...] Is there any reason why this one wasnt applied?
I don't know, but here it is an updated patch.
looks ok btw, maybe you are interrested in porting the RC improvments from x264 to ffmpeg? :) [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
On date Friday 2008-11-28 17:24:26 +0100, Michael Niedermayer encoded:
On Thu, Nov 27, 2008 at 11:50:28PM +0100, Stefano Sabatini wrote:
On date Wednesday 2008-11-26 01:33:33 +0100, Michael Niedermayer encoded:
On Wed, Dec 05, 2007 at 04:46:14PM +0100, Stefano Sabatini wrote:
On date Monday 2007-11-19 11:09:34 +0100, Stefano Sabatini encoded:
On date Tuesday 2007-10-16 22:20:17 +0200, Michael Niedermayer encoded:
On Tue, Oct 16, 2007 at 12:17:26PM +0200, Baptiste Coudurier wrote: [...] > Patch attached.
ok
I'm interested in this patch too. Since Michael OKed it could someone apply it?
I diffed the previous patch against the latest SVN, in order to get a clean patch.
Ping + patch diffed against latest SVN. I also added a bump to libavcodec minor. [...] Is there any reason why this one wasnt applied?
I don't know, but here it is an updated patch.
looks ok
Applied.
btw, maybe you are interrested in porting the RC improvments from x264 to ffmpeg? :)
I'm surely interested in that one, but in the short time I want prioritize my work on other things (especially on libavfilter), anyway it's cool that you have interest in improving the RC system :-). Regards. -- FFmpeg = Fostering Furious Mean Portable Extended Gangster
Baptiste Coudurier <baptiste.coudurier at smartjog.com> writes:
Hi,
I stumbed accross a weird behaviour of the CBR ratecontrol lately, basically doing:
ffmpeg -i file.mpg -vcodec mpeg2video -minrate 30000k -maxrate 30000k -b 30000k -intra -flags +ildct+low_delay -dc 10 -flags2 +ivlc+non_linear_q -ps 1 -qmin 1 -qmax 12 -top 1 -vglobal 4 -acodec pcm_s16be -f mov -bufsize 1200000 -rc_init_occupancy 1200000 cbr.mov
Constraints are so in order to achieve vbv delay as 3600. Now ffmpeg will only give me qp as 24. While tweaking I changed some magic in ratecontrol.c (see patch attached) and now qp have decent/good values.
In general, you cannot mix bitrate and quantizer constraints. They are interdependent, so an arbitrary combination may well be impossible to achieve. -- M?ns Rullg?rd mru at inprovide.com
participants (4)
-
baptiste.coudurier@smartjog.com -
mans@mansr.com -
michaelni@gmx.at -
stefano.sabatini-lala@poste.it