How to convert wav with custom codec to mp3? - python

I've received a set of .wav files which are encoded with a custom codec. I wish to convert these files to .mp3 (or really any standard audio format that other software will recognize).
The codec has been provided to me as a .msi file, which allows me to install the codec in Windows. Running the installer creates a .acm file (in its own folder, not in the standard codec location which seems to be c:\windows\system32 ). Once I do so, Windows Media Player will play the audio in the files. No other software will play them (I've tried Audacity, VLC, QuickTime, ...).
I've tried to convert the files using ffmpeg, but it doesn't recognize the format either.
I've attempted the technique of burning the audio to a CD (with the intent of ripping the CD as mp3), but WMP gives an error when it attempts to burn them.
I'm proficient in Python and Javascript so I don't mind coding a solution if that's possible--I'm not really familiar with the theory of audio codecs. I looked at a couple python libraries but they didn't seem able to do anything with the .msi file I've been given.
Can anyone suggest a solution? Solutions might include:
How to point ffmpeg or Audacity or VLC to the installed codec so that it is able to play/convert the files?
Point me to some resources/libraries/code snippets for coding a converter based on the supplied .acm file?
How to convice WMP to save these files in some other format?

Related

I need help dealing with converting Audio Files to MP4 with python

So, I am a beginner in Pyhton and recently I have covered what would be the basics of the language.
And now I have this little project in mind which is basically to create a script that can convert files in a massive way. Specifically convert .ogg files into .mp4 or .mkv files. The intention of this is to convert whatsapp audio files that come in .ogg format to make them more manipulable.
I would like hints suggestions and guidance on how I could do this. Which lib could I use to help me and where can I learn more about this and file conversion using python
Not a python user, but will try to give you some direction.
There is a software called ffmpeg. It can be used as a command line tool to convert any audio/video files to almost any format. If you decide to use it manually then you need to download binaries here, put your .ogg file in the /bin directory next to ffmpeg.exe file and execute (here is the screenshot for better understanding):
./ffmpeg.exe -i input.ogg output.mp4
or:
./ffmpeg.exe -i input.ogg -c copy output.mp4
These are only basic commands, for more examples check this answer.
But I would suggest to simply use a python wrapper of this tool that is already implemented, check this quick start guide with lots of examples in python. For more details this answer can be also helpful.

No download module to manipulate sound with MP3 in Python?

I'm looking to make an audio editor using Python for a project in which I'm not allowed to use modules that need be downloaded (I can only do a simple import ).
I want to be able to have users upload a file (preferably in mp3 or some other common format for all operating systems) and be able to play back and edit it. I also need to write out a mp3 file with the new audio.
Would this be feasible in Python 2.7 without outside modules?
EDIT: This will be hosted online if that makes any difference.
Would any of these audio modules help?
audioop is a built-in module to manipulate raw audio data. It requires a format such as .WAV but you could either convert that separately or in the program.
If you want to simply upload wav files to be used with audioop, consider looking at the wave module.

Detecting audio file integrity with python

If I download an audio file from the web and something bad happens to the download process, how does one efficiently detect that the audio file is incomplete with python?
There are some ideas, such as using the file command in linux:
file audio.mp4
But it recognizes that it's mp4:
audio.mp4: ISO Media, MPEG v4 system, version 2
Even mplayer detects the mp4 audio type, but fails when trying to play. I don't think launching mplayerfrom python and checking if it failed is a scalable solution though.
Here is a sample of broken file:
https://www.dropbox.com/s/5rpscb9r1xrrx4t/They
The sample above fails with mutagen and mp4file, causing them to hang indefinitely. It has to do with fileObject.tell().
There are many different audio file formats, and container formats for things that that may or may not be audio files.
Fortunately, there are libraries that can a wide variety of different kinds of files. And there are Python wrappers for:
Portable command-line tools like ffmpeg and mplayer.
Portable libraries like libavcodec (what ffmpeg uses).
Platform-specific libraries like Core Audio or QuickTime or Windows Media.
If you're willing to use separate wrappers for separate file types, there are even more choices (e.g., libmp4v2 is great for MP4 files, but useless for anything else).
Of course there are huge tradeoffs—the more powerful libraries are often going to be more complex, or have more prerequisites. Do some searching at http://pypi.python.org/ to see what turns up; you should be able to find something that does everything you want.
For one really simple example, mp4file will attempt to parse any MPEG4 container. If it's incomplete, or has any invalid atoms, you'll get an exception. So, the check is just one line, mp4file.Mp4File(path). If it succeeds, it's complete; if it throws an exception, it's incomplete or invalid. But of course this will accept a complete MPEG4 video file, or MPEG4 with no audio or video in it, and it will reject a complete MP3, or even a complete M4A with one broken metadata tag.

Python module that would create mp42 encoded ASF file

I'm trying to capture a video using a webcam then encoding it as an mp42 asf file on a windows machine.
I managed to encode an mpeg2 file using pymedia but pymedia doesn't seem to support mp42.
I installed opencv and tried to use the python wrapper but python keeps crashing everytime I create a writer. Even with just captureing images, it seems too slow and unreliable.
Does anyone know of a python module that allow me to create mp42 files?
Thanks,
-Ray
According to this : http://forums.creativecow.net/readpost/291/493 mp42 is a version 2 of MP4 ISO file format. (Explained here)
Where as according to this wiki link, it is an old Microsoft's (proprietary) MPEG4 codec version 2. This was built-in under VFW (video for windows). I think FFMPEG allows encoding using -vcodec MSMPEGv2 (or something like that) as per this link: http://ffmpeg.org/general.html#Video-Codecs. Though i am not sure if this is same.
If FFMPEG works, it has python binding pyffmpeg that might work for you.

Best python solution to play ALL kinds of audio on Windows (and Linux)?

I'm trying to write some scripts to play some of my music collection with python. Finding python modules that will play ogg and mp3 is not a problem. However, I'm having repeated failures with aac-encoded m4a files from iTunes (not DRM). pygame's audio machinery doesn't support them, so I tried pymedia:
a = pymedia.player.Player()
a.start()
a.startPlayback("myM4a.m4a", format='aac')
I've tried several versions of the last line of code, including omitting the format argument, changing the files to mp4, etc. mp3's work fine, however.
pymedia even claims to support aac encoded files, but the project appears to have been abandoned anyway.
Is there a good, up to date, solution for playing ALL types of audio in python? What is used by existing python media centers/players?
I should add that I intend to use this primarily on windows, so windows support for the library is a must, but cross-platform would obviously be preferable.
You should look at the gStreamer API. It has plugins for many major audio types, is used by many audio players including Banshee and Rhythmbox and it can run on Linux, Windows and Mac. It has Python bindings as well as bindings for many other languages:
http://gstreamer.freedesktop.org/bindings/
MPlayer plays most known audio formats, and there's Python wrapper for it:
http://code.google.com/p/python-mplayer/
And a list of audio codecs supported by MPlayer:
http://www.mplayerhq.hu/DOCS/codecs-status.html#ac

Categories

Resources