[Bf-blender-cvs] [956cb4f403d] master: Fix T65803: MPEG4 unsupported timebase denominator

Sybren A. Stüvel noreply at git.blender.org
Fri Jun 14 13:37:48 CEST 2019


Commit: 956cb4f403dd3a6ddb379202dc1f2770b9820073
Author: Sybren A. Stüvel
Date:   Fri Jun 14 13:36:05 2019 +0200
Branches: master
https://developer.blender.org/rB956cb4f403dd3a6ddb379202dc1f2770b9820073

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 c5b1e7cd4e86f9aff010fa84192d783b895ce6c7
where the correct ratio was passed to FFmpeg, but not with the identical
numbers FFmpeg has in a lookup table.

===================================================================

M	source/blender/blenkernel/intern/writeffmpeg.c

===================================================================

diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index fb8bfa1dfd9..e31e7fb5b63 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -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;



More information about the Bf-blender-cvs mailing list