@@ -1162,21 +1162,14 @@ def decode(self, source=None) -> torch.Tensor:
11621162 def test_video_encoder_round_trip (self , tmp_path , format , method ):
11631163 # Test that decode(encode(decode(frames))) == decode(frames)
11641164 ffmpeg_version = get_ffmpeg_major_version ()
1165- # In FFmpeg6, the default codec's best pixel format is lossy for all container formats but webm.
1166- # As a result, we skip the round trip test.
1167- if ffmpeg_version == 6 and format != "webm" :
1168- pytest .skip (
1169- f"FFmpeg6 defaults to lossy encoding for { format } , skipping round-trip test."
1170- )
11711165 if format == "webm" and (
11721166 ffmpeg_version == 4 or (IS_WINDOWS and ffmpeg_version in (6 , 7 ))
11731167 ):
11741168 pytest .skip ("Codec for webm is not available in this FFmpeg installation." )
11751169 source_frames = self .decode (TEST_SRC_2_720P .path ).data
11761170
1177- params = dict (
1178- frame_rate = 30 , crf = 0
1179- ) # Frame rate is fixed with num frames decoded
1171+ # Frame rate is fixed with num frames decoded
1172+ params = dict (frame_rate = 30 , pixel_format = "yuv444p" , crf = 0 )
11801173 if method == "to_file" :
11811174 encoded_path = str (tmp_path / f"encoder_output.{ format } " )
11821175 encode_video_to_file (
@@ -1274,16 +1267,18 @@ def test_against_to_file(self, tmp_path, format, method):
12741267 "avi" ,
12751268 "mkv" ,
12761269 "flv" ,
1277- "gif" ,
12781270 pytest .param ("webm" , marks = pytest .mark .slow ),
12791271 ),
12801272 )
1281- def test_video_encoder_against_ffmpeg_cli (self , tmp_path , format ):
1273+ @pytest .mark .parametrize ("pixel_format" , ("yuv444p" , "yuv420p" ))
1274+ def test_video_encoder_against_ffmpeg_cli (self , tmp_path , format , pixel_format ):
12821275 ffmpeg_version = get_ffmpeg_major_version ()
12831276 if format == "webm" and (
12841277 ffmpeg_version == 4 or (IS_WINDOWS and ffmpeg_version in (6 , 7 ))
12851278 ):
12861279 pytest .skip ("Codec for webm is not available in this FFmpeg installation." )
1280+ if format in ("avi" , "flv" ) and pixel_format == "yuv444p" :
1281+ pytest .skip (f"Default codec for { format } does not support { pixel_format } " )
12871282
12881283 source_frames = self .decode (TEST_SRC_2_720P .path ).data
12891284
@@ -1303,13 +1298,15 @@ def test_video_encoder_against_ffmpeg_cli(self, tmp_path, format):
13031298 "-f" ,
13041299 "rawvideo" ,
13051300 "-pix_fmt" ,
1306- "rgb24" ,
1301+ "rgb24" , # Input format
13071302 "-s" ,
13081303 f"{ source_frames .shape [3 ]} x{ source_frames .shape [2 ]} " ,
13091304 "-r" ,
13101305 str (frame_rate ),
13111306 "-i" ,
13121307 temp_raw_path ,
1308+ "-pix_fmt" ,
1309+ pixel_format , # Output format
13131310 "-crf" ,
13141311 str (crf ),
13151312 ffmpeg_encoded_path ,
@@ -1322,6 +1319,7 @@ def test_video_encoder_against_ffmpeg_cli(self, tmp_path, format):
13221319 frames = source_frames ,
13231320 frame_rate = frame_rate ,
13241321 filename = encoder_output_path ,
1322+ pixel_format = pixel_format ,
13251323 crf = crf ,
13261324 )
13271325
@@ -1362,7 +1360,12 @@ def get_encoded_data(self):
13621360 source_frames = self .decode (TEST_SRC_2_720P .path ).data
13631361 file_like = CustomFileObject ()
13641362 encode_video_to_file_like (
1365- source_frames , frame_rate = 30 , crf = 0 , format = "mp4" , file_like = file_like
1363+ source_frames ,
1364+ frame_rate = 30 ,
1365+ pixel_format = "yuv444p" ,
1366+ crf = 0 ,
1367+ format = "mp4" ,
1368+ file_like = file_like ,
13661369 )
13671370 decoded_samples = self .decode (file_like .get_encoded_data ())
13681371
@@ -1380,7 +1383,12 @@ def test_to_file_like_real_file(self, tmp_path):
13801383
13811384 with open (file_path , "wb" ) as file_like :
13821385 encode_video_to_file_like (
1383- source_frames , frame_rate = 30 , crf = 0 , format = "mp4" , file_like = file_like
1386+ source_frames ,
1387+ frame_rate = 30 ,
1388+ pixel_format = "yuv444p" ,
1389+ crf = 0 ,
1390+ format = "mp4" ,
1391+ file_like = file_like ,
13841392 )
13851393 decoded_samples = self .decode (str (file_path ))
13861394
0 commit comments