Skip to content

Commit 912da0a

Browse files
committed
simplify metadata assert, only assert in to_file again
1 parent 82d4198 commit 912da0a

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

test/test_encoders.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -992,9 +992,6 @@ def test_video_encoder_against_ffmpeg_cli(
992992
preset=preset,
993993
)
994994
encoder_frames = self.decode(encoded_output).data
995-
# Write tensor to file to check with ffprobe
996-
with open(encoder_output_path, "wb") as f:
997-
f.write(encoded_output.numpy().tobytes())
998995
elif method == "to_file_like":
999996
file_like = io.BytesIO()
1000997
encoder.to_file_like(
@@ -1005,9 +1002,6 @@ def test_video_encoder_against_ffmpeg_cli(
10051002
preset=preset,
10061003
)
10071004
encoder_frames = self.decode(file_like.getvalue()).data
1008-
# Write file_like to file to check with ffprobe
1009-
with open(encoder_output_path, "wb") as f:
1010-
f.write(file_like.getvalue())
10111005
else:
10121006
raise ValueError(f"Unknown method: {method}")
10131007

@@ -1025,17 +1019,17 @@ def test_video_encoder_against_ffmpeg_cli(
10251019
)
10261020

10271021
# Check that video metadata is the same
1028-
fields = ["duration", "duration_ts", "r_frame_rate", "nb_frames"]
1029-
ffmpeg_metadata = self._get_video_metadata(
1030-
ffmpeg_encoded_path,
1031-
fields=fields,
1032-
)
1033-
encoder_metadata = self._get_video_metadata(
1034-
encoder_output_path,
1035-
fields=fields,
1036-
)
1037-
for key in ffmpeg_metadata:
1038-
assert ffmpeg_metadata[key] == encoder_metadata[key]
1022+
if method == "to_file":
1023+
fields = ["duration", "duration_ts", "r_frame_rate", "nb_frames"]
1024+
ffmpeg_metadata = self._get_video_metadata(
1025+
ffmpeg_encoded_path,
1026+
fields=fields,
1027+
)
1028+
encoder_metadata = self._get_video_metadata(
1029+
encoder_output_path,
1030+
fields=fields,
1031+
)
1032+
assert ffmpeg_metadata == encoder_metadata
10391033

10401034
def test_to_file_like_custom_file_object(self):
10411035
"""Test to_file_like with a custom file-like object that implements write and seek."""

0 commit comments

Comments
 (0)