From 23be4d57fe64dd0024b200393f831e4dbd7a2b4f Mon Sep 17 00:00:00 2001 From: Nunatic02 <58194485+Nunatic02@users.noreply.github.com> Date: Tue, 12 Sep 2023 17:52:23 +0800 Subject: [PATCH] correct `fps` parsing (#84) * parse data from input source instead of output source * set fps as fps parsed instead of tbr parsed * fix unit test for hard coded fps --- imageio_ffmpeg/_parsing.py | 5 ++--- tests/test_parsing.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/imageio_ffmpeg/_parsing.py b/imageio_ffmpeg/_parsing.py index b32ea35..8dd71b8 100644 --- a/imageio_ffmpeg/_parsing.py +++ b/imageio_ffmpeg/_parsing.py @@ -161,9 +161,8 @@ def parse_ffmpeg_header(text): # the regexp omits values of "1k tbr" which seems a specific edge-case #262 # it seems that tbr is generally to be preferred #262 fps = 0 - for line in (videolines[0], videolines[-1]): - matches = re.findall(r" ([0-9]+\.?[0-9]*) (tbr|fps)", line) - matches.sort(key=lambda x: x[1] == "tbr", reverse=True) + for line in [videolines[0]]: + matches = re.findall(r" ([0-9]+\.?[0-9]*) (fps)", line) if matches: fps = float(matches[0][0].strip()) meta["fps"] = fps diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 74d0c13..e83bd9b 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -74,7 +74,7 @@ def test_get_correct_fps1(): ) info = parse_ffmpeg_header(sample) - assert info["fps"] == 26.58 + assert info["fps"] == 29.46 def test_get_correct_fps2():