Search code examples
pythonaudiomp3oggaudio-converter

Simple way to convert mp3 to ogg then zip? (Python 3)


I've got a folder of mp3's I want to convert to .oggs in a specific sample/bit rate e.g. 44.1k, 160 kbps. And then zip them up individually to host online.

I put Python in the title because I enjoy using it but I'm willing to use any free software or apps as well.

Is there a library you would recommend? I found this thread: Python library for converting files to MP3 and setting their quality But it looks fairly outdated

What about for zipping files? I found https://docs.python.org/2/library/zipfile.html which seems like zipfile.zipfile and zipfile.write would cover me.

Thank you!


Solution

    1. Decode the file with lame.
    2. Encode it with the vorbis tools.
    3. Compress it with zip.

    Here without any option flags:

    lame --decode input.mp3 intermediate.wav
    oggenc intermediate.wav -o output.ogg
    zip output.zip output.ogg
    

    You can script it with Python or Bash or whatsoever.