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 = (
28+ IS_WINDOWS
29+ or (
30+ get_ffmpeg_major_version () < 7
31+ or (
32+ get_ffmpeg_major_version () == 7 and get_ffmpeg_minor_version () == 0
33+ )
34+ )
35+ )
36+
2637
2738@pytest .fixture
2839def with_ffmpeg_debug_logs ():
@@ -155,7 +166,7 @@ def test_bad_input_parametrized(self, method, tmp_path):
155166 avcodec_open2_failed_msg = "avcodec_open2 failed: Invalid argument"
156167 with pytest .raises (
157168 RuntimeError ,
158- match = avcodec_open2_failed_msg if IS_WINDOWS else "invalid sample rate=10" ,
169+ match = avcodec_open2_failed_msg if IS_WINDOWS_WITH_FFMPEG_LE_70 else "invalid sample rate=10" ,
159170 ):
160171 getattr (decoder , method )(** valid_params )
161172
@@ -164,14 +175,14 @@ def test_bad_input_parametrized(self, method, tmp_path):
164175 )
165176 with pytest .raises (
166177 RuntimeError ,
167- match = avcodec_open2_failed_msg if IS_WINDOWS else "invalid sample rate=10" ,
178+ match = avcodec_open2_failed_msg if IS_WINDOWS_WITH_FFMPEG_LE_70 else "invalid sample rate=10" ,
168179 ):
169180 getattr (decoder , method )(sample_rate = 10 , ** valid_params )
170181 with pytest .raises (
171182 RuntimeError ,
172183 match = (
173184 avcodec_open2_failed_msg
174- if IS_WINDOWS
185+ if IS_WINDOWS_WITH_FFMPEG_LE_70
175186 else "invalid sample rate=99999999"
176187 ),
177188 ):
@@ -192,7 +203,7 @@ def test_bad_input_parametrized(self, method, tmp_path):
192203 for num_channels in (0 , 3 ):
193204 match = (
194205 avcodec_open2_failed_msg
195- if IS_WINDOWS
206+ if IS_WINDOWS_WITH_FFMPEG_LE_70
196207 else re .escape (
197208 f"Desired number of channels ({ num_channels } ) is not supported"
198209 )
@@ -316,7 +327,7 @@ def test_against_cli(
316327 else :
317328 rtol , atol = None , None
318329
319- if IS_WINDOWS and format == "mp3" :
330+ if IS_WINDOWS_WITH_FFMPEG_LE_70 and format == "mp3" :
320331 # We're getting a "Could not open input file" on Windows mp3 files when decoding.
321332 # TODO: https://github.com/pytorch/torchcodec/issues/837
322333 return
@@ -370,7 +381,7 @@ def test_against_to_file(
370381 else :
371382 raise ValueError (f"Unknown method: { method } " )
372383
373- if not (IS_WINDOWS and format == "mp3" ):
384+ if not (IS_WINDOWS_WITH_FFMPEG_LE_70 and format == "mp3" ):
374385 # We're getting a "Could not open input file" on Windows mp3 files when decoding.
375386 # TODO: https://github.com/pytorch/torchcodec/issues/837
376387 torch .testing .assert_close (
0 commit comments