@@ -992,6 +992,9 @@ 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 ())
995998 elif method == "to_file_like" :
996999 file_like = io .BytesIO ()
9971000 encoder .to_file_like (
@@ -1002,6 +1005,9 @@ def test_video_encoder_against_ffmpeg_cli(
10021005 preset = preset ,
10031006 )
10041007 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 ())
10051011 else :
10061012 raise ValueError (f"Unknown method: { method } " )
10071013
@@ -1019,18 +1025,17 @@ def test_video_encoder_against_ffmpeg_cli(
10191025 )
10201026
10211027 # Check that video metadata is the same
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- for key in ffmpeg_metadata :
1033- assert ffmpeg_metadata [key ] == encoder_metadata [key ]
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 ]
10341039
10351040 def test_to_file_like_custom_file_object (self ):
10361041 """Test to_file_like with a custom file-like object that implements write and seek."""
0 commit comments