I was wondering if it is possible to convert audio files with python. like wma to mp3.

thanks!

Dani AI

Generated

Yes — converting files like WMA to MP3 is routine today if you use a solid encoder (FFmpeg) and drive it from Python. asked if it was possible; contributors here explored Python libraries and compatibility. A reliable, modern workflow is to install FFmpeg and either call it directly from Python for batch jobs or use a lightweight wrapper such as pydub to handle file I/O and format selection.

Example using pydub (requires FFmpeg on PATH):

from pydub import AudioSegment
audio = AudioSegment.from_file("input.wma")
audio.export("output.mp3", format="mp3", bitrate="192k")

Example calling FFmpeg directly (fast, low-memory, good for batches):

ffmpeg -i input.wma -codec:a libmp3lame -b:a 192k -map_metadata 0 output.mp3

Practical tips: install FFmpeg from the official site or your package manager so Python wrappers can find the binary. Copying metadata requires either the FFmpeg -map_metadata flag or a metadata library such as Mutagen after conversion. DRM-protected WMA files cannot be converted. Converting is lossy — you cannot increase quality beyond the source. For large batches prefer invoking FFmpeg via subprocess to avoid loading entire audio into Python memory.

Recommended references: FFmpeg for the conversion engine (ffmpeg.org) and pydub for a simple Python API (github.com/jiaaro/pydub). Thanks to and for the earlier discussion on library choices and compatibility; using an external, actively maintained encoder avoids many cross-version issues.

Recommended Answers

All 5 Replies

A quick search found this site that provides a python module and tutorials for handling and manipulating media files. It might be of some help.

thanks! this will be perfect!

PyMedia is a little old and crusty, development seems to have stopped in June 2006.

oh, yeah, it stops at py24

I got PyMedia to work with Python25 using this somewhat cumbersome edit:
Copy the pymedia installed folder from a python24 installation.
Pymedia will work with python25 if you hexedit all .pyd files (5)
in the pymedia installed folder and its subfolders.
You can use for instance the ICY hexplorer utility.
In the hexeditor find the python24.dll ref and change to python25.dll

There may be a runtime version warning, but it works otherwise.

Note:
Python26 uses the MSC 2008 compiler and not the usual MSC 2003 compiler. So the PyMedia DLL/PYD files may not be compatible.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.