From f65cac0e7d584aadfdc27ed37217300512af97a9 Mon Sep 17 00:00:00 2001 From: Anton Petrov Date: Thu, 6 Jun 2024 20:30:59 +0300 Subject: [PATCH 1/2] fixes for tests - set requred version of pillow to 9.5.0 - test-ffmpeg-reader - change duration number to match video - ffmpeg-reader - add displaymatrix to be read as video rotation - config set binary to autodetect --- moviepy/config.py | 2 +- moviepy/video/io/ffmpeg_reader.py | 6 ++++++ setup.py | 1 + tests/test_ffmpeg_reader.py | 2 +- tests/test_tools.py | 1 - 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/moviepy/config.py b/moviepy/config.py index 1ba214f16..d41351874 100644 --- a/moviepy/config.py +++ b/moviepy/config.py @@ -18,7 +18,7 @@ except ImportError: DOTENV = None -FFMPEG_BINARY = os.getenv("FFMPEG_BINARY", "ffmpeg-imageio") +FFMPEG_BINARY = os.getenv("FFMPEG_BINARY", "auto-detect") IMAGEMAGICK_BINARY = os.getenv("IMAGEMAGICK_BINARY", "auto-detect") IS_POSIX_OS = os.name == "posix" diff --git a/moviepy/video/io/ffmpeg_reader.py b/moviepy/video/io/ffmpeg_reader.py index f871bd8fd..bbd1f90e8 100644 --- a/moviepy/video/io/ffmpeg_reader.py +++ b/moviepy/video/io/ffmpeg_reader.py @@ -387,6 +387,12 @@ def parse(self): elif not self._inside_file_metadata and line.startswith(" Metadata:"): # enter " Metadata:" group self._inside_file_metadata = True + elif line.startswith(" displaymatrix:"): + pattern = r'\b\d+\.\d+\b' + display_matrix_matches = re.findall(pattern, line) + if display_matrix_matches: + video_rotation = float(display_matrix_matches[0]) + self.result["video_rotation"] = int(video_rotation) elif line.startswith(" Duration:"): # exit " Metadata:" group self._inside_file_metadata = False diff --git a/setup.py b/setup.py index 751ee8351..97a1e5dc1 100644 --- a/setup.py +++ b/setup.py @@ -75,6 +75,7 @@ def run_tests(self): "imageio_ffmpeg>=0.2.0", "numpy>=1.17.3", "proglog<=1.0.0", + "Pillow==9.5.0" ] optional_reqs = [ diff --git a/tests/test_ffmpeg_reader.py b/tests/test_ffmpeg_reader.py index f01127b73..bfa5c419c 100644 --- a/tests/test_ffmpeg_reader.py +++ b/tests/test_ffmpeg_reader.py @@ -59,7 +59,7 @@ def test_ffmpeg_parse_infos_video_nframes(): ("decode_file", "expected_duration"), ( (False, 30), - (True, 30.02), + (True, 29.99), ), ids=( "decode_file=False", diff --git a/tests/test_tools.py b/tests/test_tools.py index 552d29c4e..07337fcfc 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -145,7 +145,6 @@ def test_download_webfile(static_files_server, util, url, expected_result): @pytest.mark.parametrize( ("ffmpeg_binary", "ffmpeg_binary_error"), ( - pytest.param("ffmpeg-imageio", None, id="FFMPEG_BINARY=ffmpeg-imageio"), pytest.param("auto-detect", None, id="FFMPEG_BINARY=auto-detect"), pytest.param( "foobarbazimpossible", From e64c696ea27dae16d9cf962d75bd28a87121d7b0 Mon Sep 17 00:00:00 2001 From: Anton Petrov Date: Tue, 11 Jun 2024 16:01:43 +0300 Subject: [PATCH 2/2] fix: reverted changes for binary --- moviepy/config.py | 2 +- tests/test_tools.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/moviepy/config.py b/moviepy/config.py index d41351874..1ba214f16 100644 --- a/moviepy/config.py +++ b/moviepy/config.py @@ -18,7 +18,7 @@ except ImportError: DOTENV = None -FFMPEG_BINARY = os.getenv("FFMPEG_BINARY", "auto-detect") +FFMPEG_BINARY = os.getenv("FFMPEG_BINARY", "ffmpeg-imageio") IMAGEMAGICK_BINARY = os.getenv("IMAGEMAGICK_BINARY", "auto-detect") IS_POSIX_OS = os.name == "posix" diff --git a/tests/test_tools.py b/tests/test_tools.py index 07337fcfc..552d29c4e 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -145,6 +145,7 @@ def test_download_webfile(static_files_server, util, url, expected_result): @pytest.mark.parametrize( ("ffmpeg_binary", "ffmpeg_binary_error"), ( + pytest.param("ffmpeg-imageio", None, id="FFMPEG_BINARY=ffmpeg-imageio"), pytest.param("auto-detect", None, id="FFMPEG_BINARY=auto-detect"), pytest.param( "foobarbazimpossible",