[Bf-blender-cvs] [9770d071ff4] master: Fix T54834: VSE can't import OGG Theora video

Sergey Sharybin noreply at git.blender.org
Wed Jan 23 17:18:13 CET 2019


Commit: 9770d071ff4306ccec940d1f44169297bb3f5747
Author: Sergey Sharybin
Date:   Wed Jan 23 17:15:56 2019 +0100
Branches: master
https://developer.blender.org/rB9770d071ff4306ccec940d1f44169297bb3f5747

Fix T54834: VSE can't import OGG Theora video

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

M	intern/ffmpeg/ffmpeg_compat.h
M	tests/python/ffmpeg_tests.py

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

diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h
index bc65f19ef59..47d20113190 100644
--- a/intern/ffmpeg/ffmpeg_compat.h
+++ b/intern/ffmpeg/ffmpeg_compat.h
@@ -520,6 +520,14 @@ AVRational av_get_r_frame_rate_compat(AVFormatContext *ctx,
 	/* For until r_frame_rate was deprecated use it. */
 	return stream->r_frame_rate;
 #else
+#  ifdef AV_USING_FFMPEG
+	/* Some of the videos might have average frame rate set to, while the
+	 * r_frame_rate will show a correct value. This happens, for example, for
+	 * OGG video files saved with Blender. */
+	if (stream->avg_frame_rate.den == 0) {
+		return stream->r_frame_rate;
+	}
+#  endif
 	return stream->avg_frame_rate;
 #endif
 }
diff --git a/tests/python/ffmpeg_tests.py b/tests/python/ffmpeg_tests.py
index 3d38ebd5edc..d6e7127c35a 100755
--- a/tests/python/ffmpeg_tests.py
+++ b/tests/python/ffmpeg_tests.py
@@ -42,15 +42,29 @@ class AbstractFFmpegSequencerTest(AbstractFFmpegTest):
             "bpy.context.scene.sequence_editor_create(); " \
             "strip = bpy.context.scene.sequence_editor.sequences.new_movie(" \
             "'test_movie', %r, channel=1, frame_start=1); " \
-            "print(f'fps:{strip.fps}')" % movie.as_posix()
+            "print(f'fps:{strip.fps}'); " \
+            "print(f'duration:{strip.frame_final_duration}'); " % movie.as_posix()
 
-    def get_movie_file_fps(self, filename: pathlib.Path) -> float:
+    def get_movie_file_field(self, filename: pathlib.Path, field: str) -> str:
         script = self.get_script_for_file(filename)
         output = self.run_blender('', script)
+        prefix = field + ":"
         for line in output.splitlines():
-            if line.startswith('fps:'):
-                return float(line.split(':')[1])
-        return 0.0
+            if line.startswith(prefix):
+                return line.split(':')[1]
+        return ""
+
+    def get_movie_file_field_float(self, filename: pathlib.Path, field: str) -> float:
+        return float(self.get_movie_file_field(filename, field))
+
+    def get_movie_file_field_int(self, filename: pathlib.Path, field: str) -> float:
+        return int(self.get_movie_file_field(filename, field))
+
+    def get_movie_file_fps(self, filename: pathlib.Path) -> float:
+        return self.get_movie_file_field_float(filename, "fps")
+
+    def get_movie_file_duration(self, filename: pathlib.Path) -> float:
+        return self.get_movie_file_field_int(filename, "duration")
 
 
 class FPSDetectionTest(AbstractFFmpegSequencerTest):
@@ -72,6 +86,11 @@ class FPSDetectionTest(AbstractFFmpegSequencerTest):
             1.0,
             places=2)
 
+    def test_T54834(self):
+        self.assertEqual(
+            self.get_movie_file_duration('T54834.ogg'),
+            50)
+
 
 if __name__ == '__main__':
     parser = argparse.ArgumentParser()



More information about the Bf-blender-cvs mailing list