1616from .utils import (
1717 assert_tensor_close_on_at_least ,
1818 get_ffmpeg_major_version ,
19+ get_ffmpeg_minor_version ,
1920 in_fbcode ,
2021 IS_WINDOWS ,
2122 NASA_AUDIO_MP3 ,
2223 SINE_MONO_S32 ,
2324 TestContainerFile ,
2425)
2526
27+ IS_WINDOWS_WITH_FFMPEG_LE_70 = IS_WINDOWS and (
28+ get_ffmpeg_major_version () < 7
29+ or (get_ffmpeg_major_version () == 7 and get_ffmpeg_minor_version () == 0 )
30+ )
31+
2632
2733@pytest .fixture
2834def with_ffmpeg_debug_logs ():
@@ -155,7 +161,11 @@ def test_bad_input_parametrized(self, method, tmp_path):
155161 avcodec_open2_failed_msg = "avcodec_open2 failed: Invalid argument"
156162 with pytest .raises (
157163 RuntimeError ,
158- match = avcodec_open2_failed_msg if IS_WINDOWS else "invalid sample rate=10" ,
164+ match = (
165+ avcodec_open2_failed_msg
166+ if IS_WINDOWS_WITH_FFMPEG_LE_70
167+ else "invalid sample rate=10"
168+ ),
159169 ):
160170 getattr (decoder , method )(** valid_params )
161171
@@ -164,14 +174,18 @@ def test_bad_input_parametrized(self, method, tmp_path):
164174 )
165175 with pytest .raises (
166176 RuntimeError ,
167- match = avcodec_open2_failed_msg if IS_WINDOWS else "invalid sample rate=10" ,
177+ match = (
178+ avcodec_open2_failed_msg
179+ if IS_WINDOWS_WITH_FFMPEG_LE_70
180+ else "invalid sample rate=10"
181+ ),
168182 ):
169183 getattr (decoder , method )(sample_rate = 10 , ** valid_params )
170184 with pytest .raises (
171185 RuntimeError ,
172186 match = (
173187 avcodec_open2_failed_msg
174- if IS_WINDOWS
188+ if IS_WINDOWS_WITH_FFMPEG_LE_70
175189 else "invalid sample rate=99999999"
176190 ),
177191 ):
@@ -192,7 +206,7 @@ def test_bad_input_parametrized(self, method, tmp_path):
192206 for num_channels in (0 , 3 ):
193207 match = (
194208 avcodec_open2_failed_msg
195- if IS_WINDOWS
209+ if IS_WINDOWS_WITH_FFMPEG_LE_70
196210 else re .escape (
197211 f"Desired number of channels ({ num_channels } ) is not supported"
198212 )
@@ -316,7 +330,7 @@ def test_against_cli(
316330 else :
317331 rtol , atol = None , None
318332
319- if IS_WINDOWS and format == "mp3" :
333+ if IS_WINDOWS_WITH_FFMPEG_LE_70 and format == "mp3" :
320334 # We're getting a "Could not open input file" on Windows mp3 files when decoding.
321335 # TODO: https://github.com/pytorch/torchcodec/issues/837
322336 return
@@ -370,7 +384,7 @@ def test_against_to_file(
370384 else :
371385 raise ValueError (f"Unknown method: { method } " )
372386
373- if not (IS_WINDOWS and format == "mp3" ):
387+ if not (IS_WINDOWS_WITH_FFMPEG_LE_70 and format == "mp3" ):
374388 # We're getting a "Could not open input file" on Windows mp3 files when decoding.
375389 # TODO: https://github.com/pytorch/torchcodec/issues/837
376390 torch .testing .assert_close (
0 commit comments