Fix T65803: MPEG4 unsupported timebase denominator
- MPEG4/DivX has a maximum value of 65535 for the timebase denominator.
- MPEG1 and 2 have a list of supported frame rate ratios. These use
ratios like 24000/1001 and need those exact numbers.
This fixes an issue introduced in c5b1e7cd4e
where the correct ratio was passed to FFmpeg, but not with the identical
numbers FFmpeg has in a lookup table.
This commit is contained in:
parent
31a99a3ab4
commit
956cb4f403
Notes:
blender-bot
2023-02-14 02:12:02 +01:00
Referenced by issue #87776, Framerate detection uses decimals in base when shouldn't Referenced by issue #65803, MPEG4 unsupported timebase denominator
|
@ -42,6 +42,7 @@
|
|||
# include <AUD_Special.h>
|
||||
# endif
|
||||
|
||||
# include "BLI_math_base.h"
|
||||
# include "BLI_utildefines.h"
|
||||
|
||||
# include "BKE_global.h"
|
||||
|
@ -588,10 +589,17 @@ static AVStream *alloc_video_stream(FFMpegContext *context,
|
|||
c->time_base.den = rd->frs_sec;
|
||||
c->time_base.num = (int)rd->frs_sec_base;
|
||||
}
|
||||
else if (compare_ff(rd->frs_sec_base, 1.001f, 0.000001f)) {
|
||||
/* This converts xx/1.001 (which is used in presets) to xx000/1001 (which is used in the rest
|
||||
* of the world, including FFmpeg). */
|
||||
c->time_base.den = (int)(rd->frs_sec * 1000);
|
||||
c->time_base.num = (int)(rd->frs_sec_base * 1000);
|
||||
}
|
||||
else {
|
||||
// This calculates a fraction (DENUM_MAX / num) which approximates the scene
|
||||
// frame rate (frs_sec / frs_sec_base).
|
||||
const double DENUM_MAX = 2147483647;
|
||||
/* This calculates a fraction (DENUM_MAX / num) which approximates the scene frame rate
|
||||
* (frs_sec / frs_sec_base). It uses the maximum denominator allowed by FFmpeg.
|
||||
*/
|
||||
const double DENUM_MAX = (codec_id == AV_CODEC_ID_MPEG4) ? (1L << 16) - 1 : (1L << 31) - 1;
|
||||
const double num = (DENUM_MAX / (double)rd->frs_sec) * rd->frs_sec_base;
|
||||
|
||||
c->time_base.den = (int)DENUM_MAX;
|
||||
|
|
Loading…
Reference in New Issue