You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from pydub import AudioSegment
audio:AudioSegment = AudioSegment.from_file("./anyAudioFile.wav")
audio.export(out_f="./anyAudioFile.mp3", format="mp3", bitrate=50049) # using str(50049) instead works as expected
Expected behavior
Calling AudioSegment.export() with a bitrate value set to an integer (like 50049) should work as expected.
Actual behavior
This integer is passed directly to the Python subprocess.execute_child as an argument and throws an exception ("TypeError: expected str, bytes or os.PathLike object, not int") since the arguments collection only supports those types and doesn't know how to process an int. The .export() definition says it accepts any type for the bitrate parameter, and then extends the args collection for ffmpeg with that parameter in whatever type it's given. Python subprocess.execute_child then throws an exception because it doesn't allow an int arg.
Workaround
This issue can be worked around by converting the bitrate to a string before calling AudioSegment.export(), but this isn't clear in the documentation and could be enforced through the method definition. I'm passing an audio stream from pytube, which hands the bitrate back as an int by default, so it's something developers have to know to do.
Is there an audio file you can include to help us reproduce?
Any audio file seems to produce this issue, it's a problem running the ffmpeg command with an integer parameter when Python expects all parameters to be strings/bytes/path.
The text was updated successfully, but these errors were encountered:
I created a PR for this fix - not sure if I did this correctly and if there's something I missed, please let me know and I'll read and follow the guidance.
Steps to reproduce
Expected behavior
Calling AudioSegment.export() with a bitrate value set to an integer (like 50049) should work as expected.
Actual behavior
This integer is passed directly to the Python subprocess.execute_child as an argument and throws an exception ("TypeError: expected str, bytes or os.PathLike object, not int") since the arguments collection only supports those types and doesn't know how to process an int. The .export() definition says it accepts any type for the bitrate parameter, and then extends the args collection for ffmpeg with that parameter in whatever type it's given. Python subprocess.execute_child then throws an exception because it doesn't allow an int arg.
Workaround
This issue can be worked around by converting the bitrate to a string before calling AudioSegment.export(), but this isn't clear in the documentation and could be enforced through the method definition. I'm passing an audio stream from pytube, which hands the bitrate back as an int by default, so it's something developers have to know to do.
Your System configuration
Is there an audio file you can include to help us reproduce?
Any audio file seems to produce this issue, it's a problem running the ffmpeg command with an integer parameter when Python expects all parameters to be strings/bytes/path.
The text was updated successfully, but these errors were encountered: