Description: Amakode is a script for Amarok 1 to transcode music. It uses various external executables to do the grunt work which you will need to install separately using your package manager. More installation details on the home page.Last changelog:
Musepack support thanks to Luigi Curzi and Louis-Guillaume Fortin.
Hi,
This is a wonderful script! For some reason though, my m4a files are not getting converted. I think I have all the libraries installed. Any suggestions? Is there a log somewhere that would display the actual error?
thank you!
-david
Aloha,
any news if there are plans for a amarok 2 version? Who do I have to send a keg of beer to to convince him/her to start coding? ;-)
Greetings,
rws
Hi there. I was wondering if it would be possible to add an option so that the volume of the converted tracks gets normalised somewhere in the pipeline, before they are transfered to the portable mp3 player.
Often with podcasts, they are recorded just too quietly, so that background noise from the environment drowns out my headphones, even if I set the volume to maximum.
Apart from that, a normalisation step would ensure that all tracks are more or less of equal volume on the mobile device.
The original track's title is showing up in the target track's tags as the album name when encoding to ogg. There's a typo in the encoding flags. Line 255 is currently:
Toby:
Thank you for your work on this. I had input files that were in Windows Media format (wma), so I added one line to your script to enable support, via mplayer. Below is my patch:
*** amakode.py~ Wed Apr 22 19:21:52 2009
--- amakode.py Wed Apr 22 19:23:59 2009
***************
*** 230,235 ****
--- 230,236 ----
decode["ogg"] = ["ogg123", "-d", "wav", "-f", "-", "-"]
# XXX: this is really fugly but faad refuses to read from a pipe
decode["mp4"] = ["env", "MPLAYER_VERBOSE=-100", "mplayer", "-ao", "pcm:file=/dev/stdout", "-"]
+ decode["wma"] = ["env", "MPLAYER_VERBOSE=-100", "mplayer", "-ao", "pcm:file=/dev/stdout", "-"]
decode["m4a"] = decode["mp4"]
decode["flac"] = ["flac", "-d", "-c", "-"]
decode["wav"] = ["cat"]
I'm running Amarok2, and I'm wondering if this script works with it. It doesn't mention anywhere what versions it's compatible with.
When I went to Tools->Script Manager, selected "Get More Scripts", and searched for Amakode, it found nothing. So I downloaded the tarball from sourceforge and installed it into Amarok via the Install Script button. And nothing happened. But it is installed, because if I try to install it again Amarok says "That script is already installed". I don't know how to activate it, and since it's not listed in the list of installed scripts, I don't even know how to uninstall it.
Amakode only works with Amarok version 1.
To be honest I've not tried Amarok 2 yet, and I have no idea about what is involved in adding support.
Manual uninstallation should be as simple as deleting the appropriate directory under ~/.kde/share/apps/amarok/scripts/
Recently purchased songs from iTunes includes an atom "----" with some xml
that AtomicParsley returns with many lines and they do not begin with
"Atom". This causes the amakode.py version 1.8 to choke. I resolved this
issue with a very simple change.
diff amakode.py amakode.py.orig
137c137
< if len(fields)==4 and fields[0]=="Atom":
---
> if fields[0]=="Atom":
I logged it as a bug on SourceForge too.
Hope this helps,
Mike
the offending out put from AtomicParsley:
...
Atom "purd" contains: 2009-03-27 02:59:42
Atom "----" [iTunMOVI] contains: <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>asset-info</key>
<dict>
<key>flavor</key>
<string>2:256</string>
</dict>
</dict>
</plist>
Atom "covr" contains: 1 piece of artwork
...
Hi,
First, thank you for that script. It's very useful for somebody like me who has an Ipod with a very heterogenous music library.
I want to say too that I know nothing in Python but I went in the code and added this line
decode["mpc"] = ["mpcdec","-","-"]
under this one :
decode["wav"] = ["cat"]
and I installed this thing :
http://files.musepack.net/linux/musepack_linux_2009_02_28.tar.gz
Now, Amakode can convert mpc files to mp3 files and put them in my Ipod. There is only one problem, it seems that there is a problem with the length of the songs. What is written is not the good lenght even if the song plays perfectly.
If you are interested in adding that support, could you test.
Thanks again for that script.
Louis-Guillaume Fortin
I am needing to transcode from flac to mp3 to appease my iphone. I plan to go Amarok to USB key to iTunes to iPhone!
I have loaded Amakode and tagpy library - SuSe 10.3.
When I hit the transfer I have a warning from Amakode that the tagpy library cannot be found and therefore tags will not be encoded. Which is what happens.
I installed Amakode via the Amarok scripts "Get More Scripts" button and tagpy via the SuSe 10.3 Yast system.
Ok, so amakode thinks that tagpy is missing. Try importing that python module directly and see if it gives any clues by typing this in a console:
$ python
Python 2.5.2 (r252:60911, Oct 5 2008, 19:24:49)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tagpy
>>>
If there is nothing after the "import tagpy" line except the >>> then python thinks the module is present, and amakode is confused. I hope that doesnt happen ;-)
Maybe it will say "ImportError: No module named tagpy". If so, we need to look at why your python installation cant find your tagpy installation. What python version is it (you see I as using 2.5.2 in the output above) and what files did your tagpy installation provide?
If it says anything else, then hopefully that explains the problem.
I dont have SuSe here to test.... where did you get tagpy from? It doesnt seem to be found on http://software.opensuse.org/search.
It seems that when an m4a (or I assume aac/mp4) is encountered as the input file this kills amakode. It seems that tagpy can't handle the tag format, and amakode silently dies in the tagpywrap init function when it calls tagpy.FileRef(f.fp.name).tag()
I'm going to try a workaround using atomicparsley to deal with m4a tags. wish me luck.
OK; I've changed the script to handle mp4 tags using AtomicParsley. It's not the most elegant solution, but it works for now (though I haven't tested it extensively). There is little or no error checking done, and it doesn't check if atomicparsley is installed, but if not it should just ignore the tags for that file and still do the transcoding.
There is still the problem that tagpy crashes the script if an unexpected file is encountered (i.e. mp4) - but there is a try block in amacode, so it's likely a tagpy (or python) issue.
Also, the version number inside the file is 1.3, while this site lists 1.6...
Here's the diff to version 1.3/1.6:
(though the forum doesn't preserve whitespace and there's no option to attach a file :( )
93a94,125
> class atomicparsleywrap(dict):
> textfields = ['album', 'artist', 'title', 'comment', 'genre']
> numfields = ['year', 'track']
> allfields = textfields + numfields
>
> def __init__(self, url):
> filename = urllib.url2pathname(url)
> if (not filename.startswith("file://")):
> return
> filename = filename[7:]
>
> cmd = "AtomicParsley '" + filename + "' -t"
> for line in os.popen(cmd):
> fields = line.rstrip().split(None, 3)
> if (fields[0] == "Atom"):
> if (fields[1].lower().find('alb') != -1):
> self['album'] = fields[3]
> elif (fields[1].lower().find('art') != -1):
> self['artist'] = fields[3]
> elif (fields[1].lower().find('nam') != -1):
> self['title'] = fields[3]
> elif (fields[1].lower().find('cmt') != -1):
> self['comment'] = fields[3]
> elif (fields[1].lower().find('gnre') != -1):
> self['genre'] = fields[3]
> elif (fields[1].lower().find('day') != -1):
> try: self['year'] = int(fields[3])
> except ValueError: self['year'] = 0
> elif (fields[1].lower().find('trkn') != -1):
> try: self['track'] = int(fields[3].split()[0])
> except ValueError: self['track'] = 0
>
156a189,192
> # list of mp4 extensions to use atomicparsley with
> # (tagpy seems to silently die on mp4/m4a files)
> mp4_ext = ("mp4", "m4a")
>
199,200c235,239
< if (have_tagpy and self.tofmt in self.tagopt):
< taginfo = tagpywrap(self.inurl)
---
> if (have_tagpy and self.tofmt in self.tagopt):
> if (self.inext in self.mp4_ext):
> taginfo = atomicparsleywrap(self.inurl)
> else:
> taginfo = tagpywrap(self.inurl)
I keep having the same problem. It works fine for a while and then quits working just showing an error like "cannot transcode". The /tmp dir then fills with 0 byte transcode-* files.
Then I quit amarok, restart it and it works again.
Any idea what it might be? Can I test something? I'm working with yesterdays SVN version.
The last log file before it stops working (I assume that's it) shows
"Error writing mp3 output
Error: buffer write failed."
I have tmp mounted with a 128M tmpfs.
The "Error writing mp3 output" message comes from lame - it is having problems writing the mp3 file in /tmp/ which amarok would later move onto your player.
I suspect your /tmp/ filesystem was getting full. If there are lots of large mp3 files left in your /tmp/ directory then maybe you need to tick Amarok's "remove transcoded files after transfer" option in the device configuration page.
Are you transcoding a particularly long track? Anything much over an hour might not fit on your /tmp/ even if nothing else is using any space there.
Feel free to mail me your full error log. My email address is linked on http://www.tarind.com/amakode.html
(Its not good that the zero byte files are getting left behind, but I dont think this is your original problem)
If you want to switch to using a different directory, add a line like this immediately after the "import tempfile" line (line 55).
tempfile.tempdir = '/var/tmp/'
Hi, I already have a different fix for that problem in SVN. You may want to check out that beta version from sourceforge at http://sourceforge.net/svn/?group_id=238313
I expect version 1.6 including this fix to be released this week.
Thanks
Daniel has kindly allowed me to pick up maintenance of Amakode now that he is no longer using it. I have some bug fixes in the pipeline which I hope to have ready to release asap.
Please check out sourceforge for beta versions, or reporting any bugs.
Hello there,
I'm trying to automatically convert flac files from my collection to wav as my audio player cannot handle flac itself. The Encoding path flac->mp3 works flawlessly, but I fail to setup flac->wav as the script has no encoding option for wav. I'm not familiar with python, so maybe somebody can tell me how to simply "encode"/save the wav stream.
thx alot
Ratings & Comments
48 Comments
Hi, This is a wonderful script! For some reason though, my m4a files are not getting converted. I think I have all the libraries installed. Any suggestions? Is there a log somewhere that would display the actual error? thank you! -david
Aloha, any news if there are plans for a amarok 2 version? Who do I have to send a keg of beer to to convince him/her to start coding? ;-) Greetings, rws
Hi there. I was wondering if it would be possible to add an option so that the volume of the converted tracks gets normalised somewhere in the pipeline, before they are transfered to the portable mp3 player. Often with podcasts, they are recorded just too quietly, so that background noise from the environment drowns out my headphones, even if I set the volume to maximum. Apart from that, a normalisation step would ensure that all tracks are more or less of equal volume on the mobile device.
I am thinking about changing the transcoding pipeline to make more use of sox, which should make normalisation easy. Thanks for the suggestion.
The original track's title is showing up in the target track's tags as the album name when encoding to ogg. There's a typo in the encoding flags. Line 255 is currently: it should be Other than that it works great for me, thanks!
good catch! thanks.
Toby: Thank you for your work on this. I had input files that were in Windows Media format (wma), so I added one line to your script to enable support, via mplayer. Below is my patch: *** amakode.py~ Wed Apr 22 19:21:52 2009 --- amakode.py Wed Apr 22 19:23:59 2009 *************** *** 230,235 **** --- 230,236 ---- decode["ogg"] = ["ogg123", "-d", "wav", "-f", "-", "-"] # XXX: this is really fugly but faad refuses to read from a pipe decode["mp4"] = ["env", "MPLAYER_VERBOSE=-100", "mplayer", "-ao", "pcm:file=/dev/stdout", "-"] + decode["wma"] = ["env", "MPLAYER_VERBOSE=-100", "mplayer", "-ao", "pcm:file=/dev/stdout", "-"] decode["m4a"] = decode["mp4"] decode["flac"] = ["flac", "-d", "-c", "-"] decode["wav"] = ["cat"]
I'm running Amarok2, and I'm wondering if this script works with it. It doesn't mention anywhere what versions it's compatible with. When I went to Tools->Script Manager, selected "Get More Scripts", and searched for Amakode, it found nothing. So I downloaded the tarball from sourceforge and installed it into Amarok via the Install Script button. And nothing happened. But it is installed, because if I try to install it again Amarok says "That script is already installed". I don't know how to activate it, and since it's not listed in the list of installed scripts, I don't even know how to uninstall it.
Amakode only works with Amarok version 1. To be honest I've not tried Amarok 2 yet, and I have no idea about what is involved in adding support. Manual uninstallation should be as simple as deleting the appropriate directory under ~/.kde/share/apps/amarok/scripts/
Hi, Thanks for the feedback. All the feature patches and bugs mentioned above should be included in the 1.9 version. Keep the patches coming....
Recently purchased songs from iTunes includes an atom "----" with some xml that AtomicParsley returns with many lines and they do not begin with "Atom". This causes the amakode.py version 1.8 to choke. I resolved this issue with a very simple change. diff amakode.py amakode.py.orig 137c137 < if len(fields)==4 and fields[0]=="Atom": --- > if fields[0]=="Atom": I logged it as a bug on SourceForge too. Hope this helps, Mike
the offending out put from AtomicParsley: ... Atom "purd" contains: 2009-03-27 02:59:42 Atom "----" [iTunMOVI] contains: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>asset-info</key> <dict> <key>flavor</key> <string>2:256</string> </dict> </dict> </plist> Atom "covr" contains: 1 piece of artwork ...
Hi, First, thank you for that script. It's very useful for somebody like me who has an Ipod with a very heterogenous music library. I want to say too that I know nothing in Python but I went in the code and added this line decode["mpc"] = ["mpcdec","-","-"] under this one : decode["wav"] = ["cat"] and I installed this thing : http://files.musepack.net/linux/musepack_linux_2009_02_28.tar.gz Now, Amakode can convert mpc files to mp3 files and put them in my Ipod. There is only one problem, it seems that there is a problem with the length of the songs. What is written is not the good lenght even if the song plays perfectly. If you are interested in adding that support, could you test. Thanks again for that script. Louis-Guillaume Fortin
I am needing to transcode from flac to mp3 to appease my iphone. I plan to go Amarok to USB key to iTunes to iPhone! I have loaded Amakode and tagpy library - SuSe 10.3. When I hit the transfer I have a warning from Amakode that the tagpy library cannot be found and therefore tags will not be encoded. Which is what happens. I installed Amakode via the Amarok scripts "Get More Scripts" button and tagpy via the SuSe 10.3 Yast system.
Ok, so amakode thinks that tagpy is missing. Try importing that python module directly and see if it gives any clues by typing this in a console: $ python Python 2.5.2 (r252:60911, Oct 5 2008, 19:24:49) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import tagpy >>> If there is nothing after the "import tagpy" line except the >>> then python thinks the module is present, and amakode is confused. I hope that doesnt happen ;-) Maybe it will say "ImportError: No module named tagpy". If so, we need to look at why your python installation cant find your tagpy installation. What python version is it (you see I as using 2.5.2 in the output above) and what files did your tagpy installation provide? If it says anything else, then hopefully that explains the problem. I dont have SuSe here to test.... where did you get tagpy from? It doesnt seem to be found on http://software.opensuse.org/search.
It seems that when an m4a (or I assume aac/mp4) is encountered as the input file this kills amakode. It seems that tagpy can't handle the tag format, and amakode silently dies in the tagpywrap init function when it calls tagpy.FileRef(f.fp.name).tag() I'm going to try a workaround using atomicparsley to deal with m4a tags. wish me luck.
OK; I've changed the script to handle mp4 tags using AtomicParsley. It's not the most elegant solution, but it works for now (though I haven't tested it extensively). There is little or no error checking done, and it doesn't check if atomicparsley is installed, but if not it should just ignore the tags for that file and still do the transcoding. There is still the problem that tagpy crashes the script if an unexpected file is encountered (i.e. mp4) - but there is a try block in amacode, so it's likely a tagpy (or python) issue. Also, the version number inside the file is 1.3, while this site lists 1.6... Here's the diff to version 1.3/1.6: (though the forum doesn't preserve whitespace and there's no option to attach a file :( ) 93a94,125 > class atomicparsleywrap(dict): > textfields = ['album', 'artist', 'title', 'comment', 'genre'] > numfields = ['year', 'track'] > allfields = textfields + numfields > > def __init__(self, url): > filename = urllib.url2pathname(url) > if (not filename.startswith("file://")): > return > filename = filename[7:] > > cmd = "AtomicParsley '" + filename + "' -t" > for line in os.popen(cmd): > fields = line.rstrip().split(None, 3) > if (fields[0] == "Atom"): > if (fields[1].lower().find('alb') != -1): > self['album'] = fields[3] > elif (fields[1].lower().find('art') != -1): > self['artist'] = fields[3] > elif (fields[1].lower().find('nam') != -1): > self['title'] = fields[3] > elif (fields[1].lower().find('cmt') != -1): > self['comment'] = fields[3] > elif (fields[1].lower().find('gnre') != -1): > self['genre'] = fields[3] > elif (fields[1].lower().find('day') != -1): > try: self['year'] = int(fields[3]) > except ValueError: self['year'] = 0 > elif (fields[1].lower().find('trkn') != -1): > try: self['track'] = int(fields[3].split()[0]) > except ValueError: self['track'] = 0 > 156a189,192 > # list of mp4 extensions to use atomicparsley with > # (tagpy seems to silently die on mp4/m4a files) > mp4_ext = ("mp4", "m4a") > 199,200c235,239 < if (have_tagpy and self.tofmt in self.tagopt): < taginfo = tagpywrap(self.inurl) --- > if (have_tagpy and self.tofmt in self.tagopt): > if (self.inext in self.mp4_ext): > taginfo = atomicparsleywrap(self.inurl) > else: > taginfo = tagpywrap(self.inurl)
I keep having the same problem. It works fine for a while and then quits working just showing an error like "cannot transcode". The /tmp dir then fills with 0 byte transcode-* files. Then I quit amarok, restart it and it works again. Any idea what it might be? Can I test something? I'm working with yesterdays SVN version.
The last log file before it stops working (I assume that's it) shows "Error writing mp3 output Error: buffer write failed." I have tmp mounted with a 128M tmpfs.
The "Error writing mp3 output" message comes from lame - it is having problems writing the mp3 file in /tmp/ which amarok would later move onto your player. I suspect your /tmp/ filesystem was getting full. If there are lots of large mp3 files left in your /tmp/ directory then maybe you need to tick Amarok's "remove transcoded files after transfer" option in the device configuration page. Are you transcoding a particularly long track? Anything much over an hour might not fit on your /tmp/ even if nothing else is using any space there. Feel free to mail me your full error log. My email address is linked on http://www.tarind.com/amakode.html (Its not good that the zero byte files are getting left behind, but I dont think this is your original problem)
If you want to switch to using a different directory, add a line like this immediately after the "import tempfile" line (line 55). tempfile.tempdir = '/var/tmp/'
Hello I've had a problem using amakode : my system's locale are utf8 and when a tag contained utf8 characters I got an error like "ascii codec can't handle this". I simply added .encode('iso8859-15') to tags : 83,86c83,86 < self['album'] = self.tagInfo.album.strip() < self['artist'] = self.tagInfo.artist.strip() < self['title'] = self.tagInfo.title.strip() < self['comment'] = self.tagInfo.comment.strip() --- > self['album'] = self.tagInfo.album.strip().encode('iso-8859-15') > self['artist'] = self.tagInfo.artist.strip().encode('iso-8859-15') > self['title'] = self.tagInfo.title.strip().encode('iso-8859-15') > self['comment'] = self.tagInfo.comment.strip().encode('iso-8859-15') 88c88 < self['genre'] = self.tagInfo.genre.strip() --- > self['genre'] = self.tagInfo.genre.strip().encode('iso-8859-15') 89a90 > hope you find it useful.
Hi, I already have a different fix for that problem in SVN. You may want to check out that beta version from sourceforge at http://sourceforge.net/svn/?group_id=238313 I expect version 1.6 including this fix to be released this week. Thanks
Daniel has kindly allowed me to pick up maintenance of Amakode now that he is no longer using it. I have some bug fixes in the pipeline which I hope to have ready to release asap. Please check out sourceforge for beta versions, or reporting any bugs.
Hello there, I'm trying to automatically convert flac files from my collection to wav as my audio player cannot handle flac itself. The Encoding path flac->mp3 works flawlessly, but I fail to setup flac->wav as the script has no encoding option for wav. I'm not familiar with python, so maybe somebody can tell me how to simply "encode"/save the wav stream. thx alot