Audio Format Converter
Amarok 1.x Scripts
Score 50%
Description:

This script allows you to convert the audio format of the tracks in the playlist. The script takes a snapshot of the current playlist. Once the conversion has started, you can go back to using amaroK normally.

Supported files for both input and output include .flac, .ogg, .mp3, .mpc, .m4a, and .wav. Additionally, .wma, .ra, and are supported for input. (See below for the required packages.)

I don't know how to do anything with metatags from .wma or .ra. All I know is tags will get transferred to the output file if and only if the tags show up in the amaroK playlist. If they aren't there, I suggest converting the files, then using a real tag editor like Easy Tag to put them in to the converted files.

This has only been tested on amaroK 1.2.4, but it should work on any amaroK>=1.2

The original files are NOT deleted. If the output file will overwrite an existing file, a dialog will appear to ask you whether to go ahead and overwrite or to skip the track. If you try to convert a file into the format it's already in, a dialog will ask you how to handle this situation.

Depending on the number of tracks and the speed of your computer, this can take a long time to run. With each track, a passive popup will let you know what track it's processing. At any time, you can stop the script by clicking 'stop' in the amaroK script GUI.

Required Packages:
lame -- for .mp3 in and out
flac -- for .flac in and out
oggenc -- for .ogg out
oggdec -- for .ogg in
mppenc -- for .mpc out
mppdec -- for .mpc in
mplayler -- for .wma or .ra in
faad -- for .mp4/.m4a in
faac -- for .m4a out
Last changelog:

12 years ago

v 0.7.0
++++++
The improvements in this release are due to Frederick Schaer, and I (we) thank him for his help!

The improvements are: 1) It now should handle full utf-8 character encoding for all the usual tags. 2) It corrects the error noted in the comments below about IndexError/AttributeError--something which I believe only affects more recent versions of Python.

v.6.2
++++++
For myriad reasons, a file can fail to convert but the script will continue on with the next file (as intended--I don't want one corrupted file to stop a 1,000 file batch). There is now an error log in the top-level directory where your transcoded files are saved that lists any files that failed to convert.

v.6.1
++++++
--amaroK switched the track number xml tag in their playlist from "TrackNo" to "Track". This catches up with the change, but should still work on versions earlier than 1.3.

v.6
++++++
--Fixed a piping bug that could cause the script to stop after a couple of files.
--Added a check for whether the output format is the same as the input format, with a dialog for how to handle this situation.
--Added a few more included options for encoders (OTHER still allows you to set your own options.)

diogorg

10 years ago

I`m using the script to convert mp3 in ogg, and when I use on quality options the value 3 or 6, i get the musics ok, but when I chose the option "OTHER", and type any number (like 4 or 5), i get errors.

I look the script, and found the line that show the options, and for me I increment the options to 4 and 5. But, do you have any ideia to use the OTHER option?


The script is amazing, nice job.
And thank you.

Report

s4ik0

10 years ago

got this output from the error

probably something is missing (i'm not using KDE...):

sh: kdialog: command not found
sh: kdialog: command not found
sh: kdialog: command not found
sh: kdialog: command not found
Traceback (most recent call last):
File "/home/.../.kde/share/apps/amarok/scripts/formatconverter0.7.0.amarokscript/formatconverter0.7.0.py", line 286, in <module>
outputFormat, destination, fileNameConven, error_log = configure(inPacks, outPacks)
File "/home/.../.kde/share/apps/amarok/scripts/formatconverter0.7.0.amarokscript/formatconverter0.7.0.py", line 56, in configure
fileNameConven = int(os.popen("kdialog --menu \"Please select the naming convention for your files.\" \"1\" \"[base directory]/trackno_title.[ext]\" \"2\" \"[base directory]/Artist/Album/trackno_title.[ext]\" \"3\" \"[base directory]/artist_album_trackno_title.[ext]\" ").readline()[:-1])
ValueError: invalid literal for int() with base 10: ''

Report

TGM

10 years ago

Install kdebase-bin. That'll give you kdialog.

Report

bugmenot1234

8 years ago

Thank you very much!!

Worked with Ubuntu 8.10 !!!!

Report

s4ik0

10 years ago

got this output from the error

probably something is missing (i'm not using KDE...):

sh: kdialog: command not found
sh: kdialog: command not found
sh: kdialog: command not found
sh: kdialog: command not found
Traceback (most recent call last):
File "/home/.../.kde/share/apps/amarok/scripts/formatconverter0.7.0.amarokscript/formatconverter0.7.0.py", line 286, in <module>
outputFormat, destination, fileNameConven, error_log = configure(inPacks, outPacks)
File "/home/.../.kde/share/apps/amarok/scripts/formatconverter0.7.0.amarokscript/formatconverter0.7.0.py", line 56, in configure
fileNameConven = int(os.popen("kdialog --menu \"Please select the naming convention for your files.\" \"1\" \"[base directory]/trackno_title.[ext]\" \"2\" \"[base directory]/Artist/Album/trackno_title.[ext]\" \"3\" \"[base directory]/artist_album_trackno_title.[ext]\" ").readline()[:-1])
ValueError: invalid literal for int() with base 10: ''

Report

gzu

10 years ago

Some of my files have the acute accent Hex 60/decimal 96 character used instead of the single quote 27/39 and it is causing problems (crashes). Can these be automatically replaced.

Thanks,

GZU

Report

moxie

10 years ago

The scripts fails to operate when amarok can't find album/artist information. In my case a folder with .wav files (loreena mckennit album). Amarok only shows the title of the song, nothing else. This will cause the script to create a file called 00_.mp3 which it then overwrites at each song. When amarok does find all the album/artist information it works great.

Report

rominet777

11 years ago

Hi,

I also had problems while trying to encode files : it was because of 2 things :
- empty tags (like comments)
- non englich chars (accentuated french chars)

I just created a patch to hopefully handle that (for me at least, it works...)

I don't see how to link a file, please send me a p.m (I'll try to send the patch to the author anyway...)

-Cheers

Report

striscio

10 years ago

please send me the patch to gianpaolo.racca_AT_gmail_DOT_com
I have similar problems converting songs...

Report

soulrebel

11 years ago

could you add the option to have destitination directory be the source's directory?
that would be great!

thanks alot for your work!

Report

beloncio

11 years ago

Hi:

mp3 -> wav

File "/home/beloncio/.kde/share/apps/amarok/scripts/formatconverter.amarokscript/formatconverter.py", line 111, in getMetaInfo
exec getInfo[i]
File "", line 1, in ?
AttributeError: 'NoneType' object has no attribute 'nodeValue'
Why?

Thanks

Report

frufo

10 years ago

Hi I got the same error. It seems that having no Value e.g. in Comment or Genre gives an Attribute error instead of an Index error so just add an Attribute Error around line 114:

for i in range(len(getInfo)):
try:
exec getInfo[i]
except IndexError:
pass
except AttributeError:
pass
return title, artist, album, year, comment, track, genre

Report

mrnegitoro

11 years ago

Excellent plugin!

It would be neat if it could somehow pass the files through normalize ( http://www1.cs.columbia.edu/~cvaill/normalize/ ) as well.

Report

mrnegitoro

11 years ago

Excellent plugin!

It would be neat if it could somehow pass the files through normalize ( http://www1.cs.columbia.edu/~cvaill/normalize/ ) as well.

Report

doudou78

11 years ago

i launch, i follow instructions, it says it works but i don't see any files :( i tried to do with python formatconverter.py but it does the same thing an i don't see any error in terminal.
i try to convert ogg files in mp3. i really need to do it !!

please can you help me

Report

C

mlmitton

11 years ago

When you run it from the terminal, what output do you see when it runs? Anything at all? Do you see anything from oggenc or lame? And pay attention--there are many errors that won't cause the script to stop.

Report

Zargoon

11 years ago

I want to convert some .wav files but I don't know how to load them to the amoraK playlist. Any suggestons?

Report

xeper

11 years ago

This script is exactly what I have been looking for - however it does choke on Filenames/Tags that contain Unicode characters. Is this a problem with Audio Format Converter or with the encoder (in this case lame 3.96.1 from packman.links2linux.de)?

Error message is:

Traceback (most recent call last):
File "/srv/shares/home/cord/.kde/share/apps/amarok/scripts/formatconverter.amarokscript/formatconverter.py", line 273, in ?
mainEncodeLoop(outputFormat, destination, fileNameConven, dom_plist, options, checkOverwrite, checkInEqOut, transSkip, neverOver, FIELDS, INPUT, error_log)
File "/srv/shares/home/cord/.kde/share/apps/amarok/scripts/formatconverter.amarokscript/formatconverter.py", line 255, in mainEncodeLoop
doTranscode(infoPopup, decodeCommand, encodeCommand, rmWavCommand, transSkip)
File "/srv/shares/home/cord/.kde/share/apps/amarok/scripts/formatconverter.amarokscript/formatconverter.py", line 198, in doTranscode
os.system(infoPopup)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xbf' in position 95: ordinal not in range(128)

Report

C

mlmitton

11 years ago

I honestly don't know what the problem is, but AFC won't handle unicode correctly. It sucks for me, too--I could have sworn I ripped my Sigur Ros, but where is it? :) I've put a lot of time into trying to figure out how to handle unicode, but I haven't succeeded. It's probably not hard, I just don't know what I'm doing. Too short on time and too dumb.

Report

bdillahu

11 years ago

I don't know if it really works or helps, but maybe as a pointer, I got past this error by adding a

".encode( "utf-8" ) on each variable where the script complained... thus it went from:

error.write(outputFileName + "\n")
to:

error.write(outputFileName.encode( "utf-8" ) + "\n")

I had to change lines: 198, 200 and 264

I still have the problem that it creates the temp.wav file but I don't get the mp3 file (going from flac to mp3).

Report

capntripz

11 years ago

It would be great to include shorten (.shn) and Monkey's Audio (.ape) with the ability to encode or decode (I guess that is like conversion. That would be all of what I know to be the major lossless audio formats.

Report

C

mlmitton

11 years ago

Look at the earlier comments--there's one on Ape. I wrote a version of the script which, I hope, includes support for Ape. However, I haven't been able to get the Ape encoder/decoder working on my system, so I haven't been able to test it. I asked people to let me know whether it worked, but so far, no one has said either way, despite its being downloaded about 100 times.

So give it a try, and let me know. If it works, I'll include it in the release itself.

As for SHN, I actually have never heard of it before. Always been a FLAC man myself.

Report

yggdrasil

12 years ago

I'm trying to convert a bunch of *.mpc files into mp3/ogg/whatever and all this script does is filling an error log. I don't even get an appropriate error-message why the process failed. When the script finishes, it says "All Done Transcoding Your Files!", although it has done nothing.
The error-log says

The error log for Audio Format Converter script for amaorK
/home/user/01_Track.mp3

The musepac-decoder mppdec is installed.Any hints?

Report

C

mlmitton

12 years ago

Well, there's not much info to go on here. Take the python script itself and run it from a console, i.e., not from amaroK's script manager. (You can download here, unpack it, then "python ****.py" (whatever the file name actually is) Then you'll be able to see all the error output and I can be of more help.

Oh, this might be overly pedantic, just remember to have amaroK open, with some MPC files in the playlist before you run the script from console.

Also, make sure that the first panel of the script indicates that you have the package required to decode MPC.

Report

kramg

11 years ago

In my case it turned out that the script chokes when it sees a genre it doesn't recognize, like "Christmas". Any thoughts on what to do other than re-tag my whole collection?

What Genres will the script recognize?

Report

12 years ago

v 0.7.0
++++++
The improvements in this release are due to Frederick Schaer, and I (we) thank him for his help!

The improvements are: 1) It now should handle full utf-8 character encoding for all the usual tags. 2) It corrects the error noted in the comments below about IndexError/AttributeError--something which I believe only affects more recent versions of Python.

v.6.2
++++++
For myriad reasons, a file can fail to convert but the script will continue on with the next file (as intended--I don't want one corrupted file to stop a 1,000 file batch). There is now an error log in the top-level directory where your transcoded files are saved that lists any files that failed to convert.

v.6.1
++++++
--amaroK switched the track number xml tag in their playlist from "TrackNo" to "Track". This catches up with the change, but should still work on versions earlier than 1.3.

v.6
++++++
--Fixed a piping bug that could cause the script to stop after a couple of files.
--Added a check for whether the output format is the same as the input format, with a dialog for how to handle this situation.
--Added a few more included options for encoders (OTHER still allows you to set your own options.)

File (click to download) Version Description Filetype Packagetype License Downloads Date Filesize OCS-Install DL
Details
version
0.7.0
updated Apr 28 2007
added May 01 2005
downloads today
0
page views today 8