Search code examples
pythonaudiocompression

Python library for converting files to MP3 and setting their quality


I'm trying to find a Python library that would take an audio file (e.g. .ogg, .wav) and convert it into mp3 for playback on a webpage.

Also, any thoughts on setting its quality for playback would be great.

Thank you.


Solution

  • Looks like PyMedia does this:

    http://pymedia.org/

    and some more info here on converting to various formats, whilst setting the bitrate:

    http://pymedia.org/tut/recode_audio.html

    e.g.

    params= {
    'id': acodec.getCodecId('mp3'),
    'bitrate': r.bitrate,
    'sample_rate': r.sample_rate,
    'ext': 'mp3',
    'channels': r.channels }
    enc= acodec.Encoder( params )