简体   繁体   中英

Convert mp4 to .wav or mp3 with python

Does anybody have experience with converting mp4 files to .wav or mp3 files? I am able to do this in Linux (bash), but I try to do everything in Python that I do in other languages, call me an enthusiast. I have been looking over the Pymedia library, but have not made progress as of yet.

You can use Python bindings for GStreamer, and create a pipeline to do the conversion:

More info here:

http://pygstdocs.berlios.de/pygst-tutorial/pipeline.html

Example of pipeline in another SO question:

converting wav to mp3 (and vice versa) using GStreamer

You might find the python audio tools of some use. They are designed to work from command line, but being python code you can simply import the modules and integrate it in another program. This is the API documentation . From the "About" page:

Python Audio Tools are a collection of audio handling programs which work from the command line. These include programs for CD extraction, track conversion from one audio format to another, track renaming and retagging, track identification, CD burning from tracks, and more. Supports internationalized track filenames and metadata using Unicode. Works with high-definition, multi-channel audio as well as CD-quality. Track conversion uses multiple CPUs or CPU cores if available to greatly speed the transcoding process. Track metadata can be retrieved from FreeDB, MusicBrainz or compatible servers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM