Skip to content

Commit

Permalink
correct fps parsing (imageio#84)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Nunatic02 authored Sep 12, 2023
1 parent 790cc18 commit 23be4d5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions imageio_ffmpeg/_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 23be4d5

Please sign in to comment.