From 84ca7342b004add327625ac8112366b23fc8e4ab Mon Sep 17 00:00:00 2001 From: Tom Burrows Date: Tue, 6 Oct 2020 14:53:21 +0100 Subject: [PATCH 1/2] Fix BitmapClip.iter_frames() when fps != 1 (closes #1326) --- moviepy/video/VideoClip.py | 2 +- tests/test_BitmapClip.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py index 6c29ce38e..3fcd92f01 100644 --- a/moviepy/video/VideoClip.py +++ b/moviepy/video/VideoClip.py @@ -1411,7 +1411,7 @@ def __init__( VideoClip.__init__( self, - make_frame=lambda t: frame_array[int(t)], + make_frame=lambda t: frame_array[int(t * fps)], ismask=ismask, duration=duration, ) diff --git a/tests/test_BitmapClip.py b/tests/test_BitmapClip.py index b4eb2d8cd..527f3e991 100644 --- a/tests/test_BitmapClip.py +++ b/tests/test_BitmapClip.py @@ -45,5 +45,15 @@ def test_setting_duration(): assert clip.duration == 6 +def test_to_bitmap(): + bitmap = [["R"], ["R"], ["B"], ["B"], ["G"], ["G"]] + clip1 = BitmapClip(bitmap, fps=0.345) + clip2 = BitmapClip(bitmap, fps=1) + clip3 = BitmapClip(bitmap, fps=3.12345) + assert bitmap == clip1.to_bitmap() + assert bitmap == clip2.to_bitmap() + assert bitmap == clip3.to_bitmap() + + if __name__ == "__main__": pytest.main() From 114a0fffc3122ac8251f46d355619d00c2aa896c Mon Sep 17 00:00:00 2001 From: Tom Burrows Date: Tue, 6 Oct 2020 14:55:12 +0100 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c6298e08..4729aa19a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed ### Fixed +- Fixed BitmapClip with fps != 1 not returning the correct frames or crashing [#1333] ## [v2.0.0.dev2](https://github.com/zulko/moviepy/tree/v2.0.0.dev2)