Skip to content

Commit

Permalink
test video with odd size
Browse files Browse the repository at this point in the history
  • Loading branch information
eberrigan committed Aug 14, 2024
1 parent 38359e7 commit a6b9709
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/io/test_videowriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,36 @@ def test_imageio_video_writer_avi(tmpdir, small_robot_mp4_vid):
assert writer.filename == out_path
assert writer.crf == 21
assert writer.preset == "superfast"


def test_imageio_video_writer_odd_size(tmpdir, movenet_video):
out_path = Path(tmpdir) / "clip.mp4"

# Reduce the size of the video frames by 1 pixel in each dimension
reduced_height = movenet_video.height - 1
reduced_width = movenet_video.width - 1

# Initialize the writer with the reduced dimensions
writer = VideoWriterImageio(
out_path,
height=reduced_height,
width=reduced_width,
fps=movenet_video.fps,
)

# Resize frames and add them to the video
for i in range(len(movenet_video) - 1):
frame = movenet_video[i][0] # Access the actual frame object
reduced_frame = cv2.resize(frame, (reduced_width, reduced_height))
writer.add_frame(reduced_frame)

writer.close()

# Assertions to validate the test
assert os.path.exists(out_path)
assert writer.height == reduced_height
assert writer.width == reduced_width
assert writer.fps == movenet_video.fps
assert writer.filename == out_path
assert writer.crf == 21
assert writer.preset == "superfast"

0 comments on commit a6b9709

Please sign in to comment.