99import pytest
1010
1111
12+ def _has_encoder (encoder_name : str ) -> bool :
13+ """Check if a given encoder is available in the local ffmpeg build."""
14+ try :
15+ result = subprocess .run (
16+ ["ffmpeg" , "-encoders" ],
17+ capture_output = True ,
18+ text = True ,
19+ )
20+ return encoder_name in result .stdout
21+ except FileNotFoundError :
22+ return False
23+
24+
1225def ffmpeg_normalize_call (args : List [str ]) -> Tuple [str , str ]:
1326 cmd = [sys .executable , "-m" , "ffmpeg_normalize" ]
1427 cmd .extend (args )
@@ -770,6 +783,11 @@ def test_replaygain_tags_stripped_ogg(self, tmp_path):
770783 temp_input = tmp_path / "test_with_replaygain.ogg"
771784 temp_output = tmp_path / "normalized_output.ogg"
772785
786+ encoder = "libvorbis" if _has_encoder ("libvorbis" ) else "vorbis"
787+ extra_args = (
788+ [] if encoder == "libvorbis" else ["-e" , "-strict experimental -ac 2" ]
789+ )
790+
773791 try :
774792 # Create a temporary copy of test.ogg with ReplayGain tags
775793 shutil .copy ("tests/test.ogg" , temp_input )
@@ -787,7 +805,7 @@ def test_replaygain_tags_stripped_ogg(self, tmp_path):
787805
788806 # Normalize the file
789807 ffmpeg_normalize_call (
790- [str (temp_input ), "-o" , str (temp_output ), "-c:a" , "libvorbis" ]
808+ [str (temp_input ), "-o" , str (temp_output ), "-c:a" , encoder ] + extra_args
791809 )
792810
793811 # Check that output file exists
0 commit comments