@@ -1432,21 +1432,39 @@ def test_video_encoder_round_trip(self, tmp_path, format, method):
14321432 assert psnr (s_frame , rt_frame ) > 30
14331433 assert_close (s_frame , rt_frame , atol = atol , rtol = 0 )
14341434
1435+ @pytest .mark .parametrize (
1436+ "format" , ("mov" , "mp4" , "avi" , "mkv" , "webm" , "flv" , "gif" )
1437+ )
1438+ def test_against_to_file (self , tmp_path , format ):
1439+ # Test that to_file and to_tensor produce the same results
1440+ ffmpeg_version = get_ffmpeg_major_version ()
1441+ if format == "webm" and (
1442+ ffmpeg_version == 4 or (IS_WINDOWS and ffmpeg_version in (6 , 7 ))
1443+ ):
1444+ pytest .skip ("Codec for webm is not available in this FFmpeg installation." )
1445+
1446+ source_frames = self .decode (TEST_SRC_2_720P .path ).data
1447+ params = dict (frame_rate = 30 , crf = 0 )
1448+
1449+ encoded_file = tmp_path / f"output.{ format } "
1450+ encode_video_to_file (frames = source_frames , filename = str (encoded_file ), ** params )
1451+ encoded_tensor = encode_video_to_tensor (source_frames , format = format , ** params )
1452+
1453+ torch .testing .assert_close (
1454+ self .decode (encoded_file ).data , self .decode (encoded_tensor ).data
1455+ )
1456+
14351457 @pytest .mark .skipif (in_fbcode (), reason = "ffmpeg CLI not available" )
14361458 @pytest .mark .parametrize (
14371459 "format" , ("mov" , "mp4" , "avi" , "mkv" , "webm" , "flv" , "gif" )
14381460 )
14391461 def test_video_encoder_against_ffmpeg_cli (self , tmp_path , format ):
14401462 ffmpeg_version = get_ffmpeg_major_version ()
1441- if format == "webm" :
1442- if ffmpeg_version == 4 :
1443- pytest .skip (
1444- "Codec for webm is not available in the FFmpeg4 installation."
1445- )
1446- if IS_WINDOWS and ffmpeg_version in (6 , 7 ):
1447- pytest .skip (
1448- "Codec for webm is not available in the FFmpeg6/7 installation on Windows."
1449- )
1463+ if format == "webm" and (
1464+ ffmpeg_version == 4 or (IS_WINDOWS and ffmpeg_version in (6 , 7 ))
1465+ ):
1466+ pytest .skip ("Codec for webm is not available in this FFmpeg installation." )
1467+
14501468 source_frames = self .decode (TEST_SRC_2_720P .path ).data
14511469
14521470 # Encode with FFmpeg CLI
0 commit comments