Embedded Album Covers, Your PSP, Amarok, and You

Amarok?So… first off, I Googled for Amarok, hoping to find some new sweet pixels and instead I find this. Um… so not the Amarok that I know and love.

Anyway, a couple of years ago, I won a PSP from the LinuxWorld convention. Being that I’m a geek, it was love at first boot jingle. Being that I am married, have 3 kids, work full-time++, and try to hack every once in a while, the brave little PSP spent a lot of alone time. Oh sure, I own several PSP games (go SOCOM2!!), but that’s about it.

Until now.

Since I’m lucky enough to be able to work from home for a bit, I’m not driving back and forth to work every day and as such, I gave my iPod to my darling daughter. So I bought a 4G memory stick (oh, that reminds me, I need to blog about stupid, evil, skanky eBay sellers of fraudulent flash memory, since I wasted my time with one personally…) (but for non-fraudulent and kick-butt flash, I highly recommend SanDisk’s Gaming Pro Duo… it’s uber fast) (and that’s enough parenthetical statements for one sentence). And, having this nice little PSP and 4G of disk space on it now, I’ve been figuring out how to put stuff of interest onto it.

Movies: Totally cool. The PSP has a 480×272 screen. Handbrake does a really nice job of ripping a DVD and creating an mp4 that the PSP can play perfectly. Really, really nice. Oooh, and the new PSP OS has this nifty little auto-generating movie browser thingey that is kind of like a scene selector on a DVD movie… lets you see scene selections for the movie at configurable intervals too… Anyway, the only beef I have with Handbrake thus far is that it doesn’t allow me to increase the volume on the ripped movie. So I’m looking at ffmpeg now to see if it does as good a job as Handbrake. I’m sure I’ll blog more about that later.

Music: Really cool here too. The PSP plays a variety of audio formats and has some really nice eye candy/visualizations/etc. for your music-listening pleasure. However (and this is what actually what prompted this post), it shows album covers per song only if they’re embedded as APIC frames in your mp3’s ID3 tag. Now, I’m new to this, and didn’t know that there were such animals as APIC frames until just yesterday, but I did know that I wanted to put my album art into my little mp3s so that they’d show up all purty-like on my PSP (there, full circle now).

So, I’ve put in the usual geekly late night or two (yes, dear, I’m honestly coming to bed… in a sec…) and learned much about ID3 tags and the various tools that one might employ in one’s attempt to embed album covers in one’s mp3s. I even bugged my good friend Seb, who pointed me to a really cool “EmbedCover” script for amarok that I didn’t know existed. But, along the learning curve, I saw a lot of complaints about Amarok showing distorted embedded album covers. My problem was slightly different in that I couldn’t figure out how to get them embedded in the first place, let alone getting them there and then finding them distorted. Through trial and error (and aforementioned geekly late nights), I think I’ve found a consistent way to get album covers to be embedded and why they might show up distorted in Amarok (and other players too, mind you–it’s not Amarok’s fault).

The first step in getting album cover art embedded in my mp3s was to get a picture into each directory of my music. I organize things like this: “Artist - Album/Artist - Title.mp3″, and in each folder, I want an album cover file. One way to do this is an amarok script called CopyCover. Assuming that you’ve first found all album art for your music via Amarok’s cover manager, CopyCover will, as you are playing your music, copy the album art from Amarok’s cache into the folder for your music and call it “cover.png”. There’s also an offline script that is supposed to do the job all at once instead of you having to do it the song-by-song way, but I couldn’t get it to work for me… I think the database schema changed behind its back. An alternate route (and this is what I did) was to tell Amarok to organize all of my music for me (highlight all tracks in player and right-click, “Manage Files” | “Organize Files”, and then click the “use cover art for folder icons” checkbox. Amarok will put a “.desktop” file in each of your folders and the “Icon” attribute will point to Amarok’s cached album cover. I then wrote this simple function to copy this album art into the folder itself:

function albumcoversfromamarok() {
for f in *
do
count=$(ls –color=never $f | grep mp3| wc -l)
echo “$count : $f”
if [ $count -gt 0 ]
then
icon=$(cat “$f/.directory” 2>/dev/null | egrep “^Icon” | cut -d “=” -f2)
[ -e "$icon" ] && cp “$icon” “$f/cover.png”
fi
done
}

I then wrote 2 more simple functions that will rip through all of my folders and embed the updated album art into my mp3s:

function mp3albumcoverdir() {
if [ -e "cover.png" ]
then
convert -quality 90 -geometry 300×300\> cover.png cover.jpg
else
return
fi
for f in *.mp3
do
echo “Embedding cover in: [$f]”
mp3albumcover “$f” cover.jpg
done
}

function mp3albumcover() {
FILENAME=”$1″
IMAGE=”$2″

# first, remove existing images
# do this for FRONT_COVER and OTHER APIC types and twice just to make sure we’re clean
eyeD3 –add-image=:OTHER “$FILENAME” >/dev/null 2>&1
eyeD3 –add-image=:OTHER “$FILENAME” >/dev/null 2>&1
eyeD3 –add-image=:FRONT_COVER “$FILENAME” >/dev/null 2>&1
eyeD3 –add-image=:FRONT_COVER “$FILENAME” >/dev/null 2>&1

# now, get rid of cruft left behind by previous images
id3v2 –APIC “” “$FILENAME” >/dev/null

# make sure we have a valid id3 tag
eyeD3 –to-v2.3 “$FILENAME” >/dev/null 2>&1
# now embed the image
eyeD3 –add-image=”$IMAGE”:FRONT_COVER “$FILENAME”
}

Then I run it from the top level of my music collection with “for f in *; do; mp3albumcoverdir “$f”; done”.

Now, along the way, whenever I found an incorrect album cover embedded and tried to fix it by removing the previous album art and adding the new one, I started seeing the corrupted images in amarok that I’d been reading about. And it’s not just that amarok wasn’t able to read the images… they were truly corrupt. “eyeD3 –write-images=. $FILE” produced a corrupt image as well. And, every time I cleared the previous image and added a new one with eyeD3, I noticed that my filesize kept getting bigger and bigger. Even when I “removed” all images with eyeD3’s “–add-image=:FRONT_COVER”, the filesize of the mp3 just kept getting bigger. It was then that I tried setting the APIC frame to null (”") with id3v2, and that returned my mp3’s filesize back to where it should be. And after that, if I added the album art to the mp3, it added it cleanly, my filesize looked sane again, and Amarok was able to see the embedded album art again.

So, my theory, which is mine, and belongs to me and I own it, and what it is too, is that people who are seeing album art distortions/corruptions in amarok might possibly have files that either have more than one embedded picture, or have dirty APIC tags. If any of you, dear readers, is seeing embedded album art distortion in Amarok, would you please install id3v2 and eyeD3 onto your little Linux box and try running my mp3albumcover function against that mp3 with a new album image? I’d very much like to see if it fixes the problem for you.

KDE project activity tracker

http://cia.navi.cx/stats/author/vanrijn.

Sweet mama, this is cool!! =:)

Dang, I need to find more time to work on code!! =:/

Look ma, I’m infamous!

me, being infamous Yay! Adriaan was nice enough to include me in the KDE people-of-PIM page! A prouder moment I’ve not had all week. =:)

In other news….

I saw Episode III, and I must say that my predictions were largely accurate, except that reading the screenplay/book was somehow worse than seeing it all movie-fied.

Real Life (TM) is sucking up far too much coding time and as such, I’ve not been able to get a chance to work on getting knotes/kpilot working all beautiful-like. This will require some changes in knotes to deal with categories and another program modifying its ics-file, etc., first before the changes can be made to kpilot, so I think I’ll probably take a look at submitting some patches for knotes along these lines, if I get a chance.

Real Life (TM), as mentioned above, includes various necessities, such as playing Street Fighter Anniversary Collection and Splinter Cell: Chaos Theory until the wee hours of the night on my Xbox. =:/ And what do I have to show for it? Really tired eyes and an overall ranking of 225, grade B fighter. =:/

Mike had his baby!!! Well, actually, Liz had the baby…. Anyway, Mike and Liz had their baby!! Congratulations, Mike!!! =:)

Anybody know how to make a living (support one’s family, etc.) working on the Open Source Desktop (KDE/Qt-development would be preferred, but anything helping to build the Open Source Desktop would be nice)? *sigh*

An example of how to not treat your users

I am always amazed at the rudeness and insensitivity that is shown by certain members of the Open Source community. This behavior is many times in stark contrast with that of others who do an outstanding job of treating others with kindness and consideration.

I know it’s not fair to generalize or put people into groups, etc., but having watched and been involved in the mailing lists for the evolution project, and the gnome community in general, there are certain inviduals who continually go out of their way to be rude, irritating, and annoying. Here’s a good example which just landed in my lap today….

The evolution GNOME groupware project had made some very nice UI changes between major version 1 and 2. There are some ugly side effects, however, and I filed a wishlist report like a good little user and it has sat for 8 months with little input from the developers. Today, it was rudely closed and marked as invalid by NotZed with the following comments:

Not Zed changed:

           What    |Removed                     |Added
-----------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

------- Additional Comments From Not Zed  2005-05-19 11:50 -------
the ui has changed, you could collapse the items, or you could
scroll once in a while - it wont kill you

That’s nice, eh? Yessirree, I’m feeling good about the time I’ve invested in the evolution community in the past. And it’s not the first time I’ve seen this sort of rude behavior in Open Source communities. And the sad thing is that the only thing this accomplishes is alienates users. It’s not helpful in the least, nor does it invite people to help make your project better, nor even to care to use it. Now, I’m by no means advocating that developers should cater to the every whim from the great, unwashed masses, but to borrow the phrase used on me above, it wouldn’t kill them to think for a second to see if there’s a usability issue that they might not have thought about.

In my case listed here, I think there is. But at the end of the day, I really don’t care anymore. This is just another reason to not care about this software, another reason for me to be thankful for the really great attitudes, atmosphere, and community that I’ve found in the KDE project, and another reason to put all my spare time and energy into helping to improve the KDE project’s solutions (like kontact, kmail, kpilot, korganizer, etc.).

My first KDE CVS commit!

I am so proud. =:) My first KDE CVS commit!

kpilot memoconduit accepted into kpilot proper!

I realize most won’t care about this, but it’s an encouragement to me nonetheless. Adriaan has kindly accepted my new memofile conduit into kpilot’s CVS repository!! =:) I need to fix it up some as soon as I get a chance and make it kde-compliant for translations, etc., and I still need to get my hand-drawn UML diagrams into a tool and into CVS to go with the code, so those are the next 2 things on my todo-list.

Speaking of UML tools….

Umbrello does a very nice job of reverse-engineering my C++ classes, but it does a lousy job with drawing the diagrams. For methods that call other methods internally (you know, like just about every method in the world does???), I can’t for the life of me get it to play nice.

Poseidon seems to be a very nice tool…. which can’t bring in existing C++ files and in which case is useless to me.

Ditto for Visual UML–and to make matters worse, I think I read that they intentionally pulled out SQD-functionality.

Describe seems to do a semi-decent job of reverse-engineering C++ files, but if it hits something that it doesn’t like, it just skips it entirely instead of trying to at least give you something to work with.

Blargh.

Does ANYONE know of a feature-complete (C++ reverse-engineering AND competent drawing functions) UML tool???

An update, whether you need it or not

Wow, been lax lately on keeping this up to date.

My kpilot memofile conduit has been released upon an unsuspecting world. And as of yet, I’ve only heard back from Adriaan about it. =:/ Guess I was hoping for someone else (other than me) to actually care about it. I guess I’ll get tons of feedback as soon as Adriaan includes it in kpilot proper and people have translation problems. =:/ DOH! I just realized that I only send my announcement to kde-pim, and not also kdepim-users. Now rectifying that.

Also, the camera that we got all excited about getting from Office Max on Black Friday has turned out to be less than the best camera in the world. We got an Olympus C-725, and there were 2 bad comments that I read going into the deal–one about the crappy battery life and the other about the crappy quality of the pictures. Well, as it turns out, these I should have heeded, because these are the 2 reasons that I now hate this camera. My lovely bride bought brand new Duracell AA batteries, and this camera has chewed through 8 of them in 6 days. The camera takes 4 AA batteries, and manages to destroy them in 3 days. And the quality of the pictures are not anything to be proud of. So I’m going to try to take the thing back to Office Max tomorrow. Here’s hoping I’m able to do so.

Still alive; kpilot memofile conduit coming along nicely

I should have known better, but I dove straight into code with my kpilot memofile conduit. To be fair, I had no clue about kpilot’s code base or classes, so it wasn’t a waste of time or anything. It was necessary, and now I have a decent understanding of how things work within kpilot. But I reached a point in my conduit where the code needed to be designed/architected, not just thrown in, so I took a break from coding for a day and looked at design. I used umbrello (kde’s UML tool), and it does a fairly nice job. My only complaint is that it doesn’t do live round trip code syncing/generation, but I due to the fact that both Poseidon and Visual Paradigm for UML don’t offer that either with their free versions, I suppose I shouldn’t complain. I don’t suppose anyone knows of a good UML tool that does live round-trip well with C++???

Anyway, I sketched out on paper 4 sequence diagrams, one for copyHHToPC, copyPCToHH, a common initialization diagram, and HotSync. I then used umbrello to import the single memofileconduit-action.h, and from there, generated a class diagram and from that class diagram created 2 new classes. Umbrello allowed me to create the attributes and operations in my class diagram that I had created on my sequence diagrams. Since it doesn’t do live round trip, though, I just had it generate code for the 2 new classes so that it didn’t touch my existing conduit class. And now, it’s just a matter of moving the code from my conduit class into the 2 new classes and writing the code for the necessary methods. =:)

If you’ve used RUP at all, you know this already, but using their methodology makes coding SO much easier. I love it because it cleanly separates the intelligent design of software from the implementation/coding of it, making sure that both get done more cleanly, better, and most probably only once to be done right. I’ll get off my soap-box now, I suppose.

I need to come back and put my sequence diagrams into a UML tool (probably umbrello) when I’m done flushing them out. I’ll likely export them to JPEGs and include both the JPEGs and XMI file in the source code for my kpilot memofile conduit so that at the least, they will make the flow of the program easier to understand and maintain.

Not a bad weekend, then. =:)

Stage two of memofile conduit: check!

I actually had this done 3 days ago, but forgot to say so….

My kpilot memofile conduit now copies and saves all memos from my Palm (Clie) to a selected directory as files, the same way gnome-pilot’s memofile conduit does.

That is all.

Stage one of KPilot memofile conduit: check

Woot! After a late-night hacking session (well, I must be getting older… 12-midnight is now “late-night”!!!), my KPIlot memofile conduit:

- shows up in Kpilot’s config dialog
- accesses the MemoDB database
- lists all memos in all categories

Coming along nicely…. =:) Next: understand gnome-pilot-conduits’ memofile.