Skip to content

Commit

Permalink
Fix incorrect behaviour from BitmapClip when fps != 1 (#1333)
Browse files Browse the repository at this point in the history
Closes #1326.
  • Loading branch information
tburrows13 committed Oct 6, 2020
1 parent 0e4bf6d commit 873530e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed <!-- for now removed features -->

### Fixed <!-- for any bug fixes -->
- 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)
Expand Down
2 changes: 1 addition & 1 deletion moviepy/video/VideoClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
10 changes: 10 additions & 0 deletions tests/test_BitmapClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 873530e

Please sign in to comment.