I have an asf file and i want to edit this file using pydub library but its not support asf file Is it possible to convert asf file to wav or mp3 in python? What library that i need to use?
-
Have you tried `ffmpeg`? It's the go-to tool for audio/video conversions. Something like `ffmpeg -i file.asf out.wav` should work..? – Greg Sadetsky Mar 19 '20 at 03:28
-
This is far too broad, and asking for library/tool recommendations is explicitly off-topic. Please see [ask], [help/on-topic]. – AMC Mar 19 '20 at 04:17
-
Thanks, but how can it be far of topic since i just i want to convert file in python, cause i dont really know how to done this in python. I think it specific enough – giri hanbudi Mar 19 '20 at 06:19
2 Answers
I would like ffmpeg, it is easy and powerful. Please look at this link example: ffmpeg -i input.wav -ar 44100 -ac 2 -b:a 192k output.mp3
-i - input file
-ar - Set the audio sampling frequency. For output streams it is set by default to the frequency of the corresponding input stream. For input streams this option only makes sense for audio grabbing devices and raw demuxers and is mapped to the corresponding demuxer options.
-ac - Set the number of audio channels. For output streams it is set by default to the number of input audio channels. For input streams this option only makes sense for audio grabbing devices and raw demuxers and is mapped to the corresponding demuxer options. So used here to make sure it is stereo (2 channels)
-b:a - Converts the audio bitrate to be exact 192kbit per second

- 16
- 3
-
thank,i figure out how its work using this ffmpeg and os library and use function os.system("ffmpeg -i filename.asf newfilename.wav") – giri hanbudi Mar 19 '20 at 06:14
The python way of using pydub. 1. Install pydub with pip install pydub and then save a file with this code 2. python code sample:
from pydub import AudioSegment
sound = AudioSegment.from_wav('input.wav')
sound.export('output.mp3', format='mp3')

- 16
- 3