Audio Format Converter

Amarok 1.x Scripts

Source i (link to git-repo or to original if based on someone elses unmodified work):

Add the source-code for this project on opencode.net

0
Become a Fan
5.0

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:

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.)


Ratings & Comments

67 Comments

diogorg

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.

s4ik0

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: ''

TGM

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

bugmenot1234

Thank you very much!! Worked with Ubuntu 8.10 !!!!

s4ik0

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: ''

gzu

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

moxie

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.

rominet777

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

striscio

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

soulrebel

could you add the option to have destitination directory be the source's directory? that would be great! thanks alot for your work!

beloncio

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

frufo

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

mrnegitoro

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

mrnegitoro

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

doudou78

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

mlmitton

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.

Zargoon

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

xeper

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)

mlmitton

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.

bdillahu

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).

capntripz

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.

mlmitton

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.

yggdrasil

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?

mlmitton

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.

kramg

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?

Pling
0 Affiliates
Details
license
version 0.7.0
updated
added
downloads 24h 0
mediaviews 24h 0
pageviews 24h 1

Other Amarok 1.x Scripts:

Gnome Play Video in Totem
mwheatland
last update date: 19 years ago

Score 5.0

editLyrics-gnome
ZeeD
last update date: 19 years ago

Score 5.0

amarok Alarm
aroth
last update date: 16 years ago

Score 5.0

amaroK Web Collection V xmms
pti-jean
last update date: 16 years ago

Score 5.0

SongLogger
lucatnt
last update date: 17 years ago

Score 5.0

amaroK Web Collection
pti-jean
last update date: 16 years ago

Score 5.0



System Tags