Open david-macias opened 5 years ago
Does pydub support all of the filetypes that ffmpeg/libav does?
@derek-adair it does, but that list depends on how your specific copy of ffmpeg/libav was compiled. The install instructions in the README have some notes about e.g., flags you can include when installing via homebrew to enable more formats
Does it just silently fail when a ffmpeg can't find the codec?
It should probably throw a warning.
@derek-adair if ffmpeg fails to convert a file while loading it rasises a pydub.exceptions.CouldntDecodeError
or during export, a pydub.exceptions.CouldntEncodeError
I think this may actually be another instance of pydub using the stdlib wave module because the output format is "wav".
I guess I'm trying to understand here (pardon the noob) @derek-adair are you suggesting that the way I installed pydub might have something to do with the my issue? The file is "converted" it's just not the format I expected. Try yourself and you'll notice that "Audio: pcm_mulaw" comes up incorrectly as compared to a file from https://archive.codeplex.com/?p=audiotestfiles which I used as my baseline for u-law format.
I am overly suspicious of installation issues, it seems this is not the case here. I'll try and find the issue, but i'm out of time at the moment.
BASICALLY - ( @jiaaro - correct me if i'm wrong ) - pydub uses the standard python lib for wav file conversions and operations. This seems to be why PyDub is not exporting ITU G.711.
PS - that audiotestfiles archive is a great resource.
This has been fixed by pull request #393. Now, nonsensical options like codec="mulaw", format="wav" result in a CouldntEncodeError. This issue can be closed now.
Steps to reproduce
sound = AudioSegment.from_mp3("speech.mp3") sound = sound.set_frame_rate(8000) sound.export("speech.wav", codec="mulaw", format="wav")
Expected behavior
Format should read: ffmpeg -i speech.wav Input #0, wav, from 'speech.wav': Duration: 00:00:02.27, bitrate: 64 kb/s Stream #0:0: Audio: pcm_mulaw ([7][0][0][0] / 0x0007), 8000 Hz, mono, s16, 64 kb/s
Actual behavior
ffmpeg -i speech.wav Input #0, wav, from 'speech.wav': Duration: 00:00:02.27, bitrate: 128 kb/s Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 8000 Hz, mono, s16, 128 kb/s
Your System configuration
Is there an audio file you can include to help us reproduce?
Any mp3 you wish to convert.