My older Digigram audio cards sometimes fail while trying to crossfade audio of different bitrates. I tried using python to convert everything new to match our existing 256k MP2. Converting WAV and MP3 worked great, but MP2 fails. The file output is blank audio, or jibberish. Here was my code:
def convertfile(audiofile):
print "\n\nConverting " + audiofile + "...\n\n"
firstname = audiofile.split(".")[0]
extension = audiofile.split(".")[-1]
try:
print "converting: " + audiofile + "\n to: " + firstname + ".WAV\n\n"
call(['avconv', '-y', '-i', audiofile, '-acodec', 'mp2', '-b', '256k', firstname + ".WAV"])
I get the following output:
avconv version 9.14-6:9.14-1rpi1rpi1, Copyright (c) 2000-2014 the Libav developers
built on Jul 22 2014 15:08:12 with gcc 4.6 (Debian 4.6.3-14+rpi1)
[mp3 @ 0x1881620] max_analyze_duration reached
[mp3 @ 0x1881620] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, mp3, from 'file1.mp2':
Duration: 00:01:02.20, start: 0.000000, bitrate: 96 kb/s
Stream #0.0: Audio: mp2, 44100 Hz, mono, s16p, 96 kb/s
Output #0, wav, to 'file1.WAV':
Metadata:
ISFT : Lavf54.20.4
Stream #0.0: Audio: mp2, 44100 Hz, mono, s16, 256 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mp2 -> mp2)
Press ctrl-c to stop encoding
Input stream #0:0 frame changed from rate:44100 fmt:s16p ch:1 chl:mono to rate:44100 fmt:s16 ch:1 chl:mono
incomplete frametime=49.31 bitrate= 255.2kbits/s
Error while decoding stream #0:0
size= 1944kB time=62.19 bitrate= 256.1kbits/s
video:0kB audio:1944kB global headers:0kB muxing overhead 0.005627%
If I read this right, avconv seems to think it's converting an MP3. I havent been able to find a way to fix this. Maybe it's something else. I am really not sure. Any help is greatly appreciated!