Kasperian Moving Parts

kinda like Batman, but with a wife and 3 kids

Monday December 10, 2007
by Jason 'vanRijn' Kasper
16 Comments

Mencoder, DVD Rip, Volume Increase, Your PSP, and You!

Holy crap. The time between iterations of testing video encoding is prohibitive to quick progress as well as a (several) good night’s sleep.

After much pain and gnashing of teeth, I present you with the result of the last 3 hours of my life.

time nice mencoder dvd://1 -sws 9 \
-aid 128 -af volume=15:0 \
-vf pullup,softskip,dsize=480:272,scale=0:0,harddup,unsharp=l3x3:0.7 \
-ofps 24000/1001 \
-oac faac -faacopts br=128:mpeg=4:object=2:raw -channels 2 -srate 48000 \
-ovc x264 -x264encopts bitrate=500:global_header:partitions=all:trellis=1:level_idc=30 \
-of lavf -lavfopts format=psp -info name=”Tomb Raider” -o “$HOME/Movies/TombRaider.mp4”

Sincere thanks to forgeflow’s answer to this ubuntu forum post and to his excellent videogeek site.

Other observations:

  • There is far more complexity to audio/video encoding than I’d ever want to understand fully.
  • Anyone who actually understands mencoder fully deserves to be the next US president.
  • No, seriously, I’d vote for him/her.
  • The above incantation of mencoder accomplishes what I need it to, namely:
    • Rips a full DVD for me without having to pull it into an intermediary file.
    • Increases the volume of the ripped/encoded track by 20 decibels in this case. Handbrake doesn’t yet let you do that.
    • Takes advantage of the newer PSP System Software’s ability to handle H264 encoding (which I hear is what all the cool kids are using these days).
  • This same thing (without being able to turn the volume up) is possible in Handbrake with this:

    ~/local/HandBrakeCLI -i /dev/dvd –longest –size 800MB -e x264 -x ref=2:mixed-refs=1:bframes=3:b-rdo=1:bime=1:weightb=1:subme=6:trellis=1:analyse=all:level=3:no-fast-pskip:me=umh –crop 0:0:0:0 -R 48 -b 1024 -w 480 -l 272 –markers -o ~/Movies/TombRaider.mp4

  • Yes, I am not ashamed to admit it: I like Tomb Raider. Angelina and I were married in an alternate dimension, and I can beat Tomb Raider Legends in 2 hours with my eyes closed.
  • One or more of the statements made in the above bullet point may be more the result of sleep-deprivation than actual truth.

Good night, Gracie.

[ Update ] Okay, nuts… apparently this video quality isn’t quite good enough because now I’m seeing weird ghosting on the PSP while watching the resultant movie. Yay, another geekly late night tonight….

[ Update 2008-03-04 ] I’ve  updated the command that I’m using now with mencoder, thanks to some comments and tweaks during the past few months.

Sunday December 9, 2007
by Jason 'vanRijn' Kasper
15 Comments

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.

Saturday December 1, 2007
by Jason 'vanRijn' Kasper
4 Comments

Ah, Now I See What You’re Talking About

SlingPlayer_700p_Angled_270x412It’s an extremely difficult thing, trying to support this weird beast, the Palm. Or, more accurately, it’s an extremely difficult thing trying to support the numerous personalities and implementations of the Palm beast. I mean, KDE PIM as a start is about as unsexy as you could want. But genius me, I focus on the ugliest duckling of KDE PIM: KPilot. Don’t get me wrong… I’m a gadget geek, enjoy Palms immensely, and have been for… gosh… 8+ years now?? (Wow, just had to check what year the IIIe came out…). And, there’s a reason that I’m hacking on KPilot, and that’s because I honestly believe it’s the best PIM-synching Palm solution in FLOSS-land.

Anyway, back to my point… The Palm OS and its devices are a moving target, and it’s darned difficult to get it right for all of them. Until just yesterday, I had been using a Treo 650 with KPilot, and it’s been working splendidly for the last couple of years. All the while, mind you, I’ve been hearing grumblings that we don’t play all that nicely with the Treo 680 or 700p. Not having any of those (expensive) devices, I was left looking stupid saying “dunno, fellas… it works purty good fer me!” Well, HAH. As of yesterday, I am now the proud owner of a Treo 700p.

I’ll not go into the details, but suffice it to say that paying $6.95 for the last year’s worth of Sprint’s Total Equipment Protection plan has now proven to be fully worth it and I’m congratulating myself on my wisdom, 1+ years ago when I agreed to partake. The speaker (and thusly the thing that notifies one of an incoming phone call) on my Treo 650 decided to up and die on me and Sprint was extremely good about replacing my Treo because of it. And, not only did they replace it, but they replaced it with a shiny new 700p. The 700p, for those not yet gadget geeks, allows me to use Sprint’s EVDO data network, which is MUCH faster than the previous data access speed I had with my 650. Like 2400-baud compared to a T3, seemingly.

Anyway, as I have a 700p of my very own, I can now appreciate the aforementioned grumblings about KPilot not playing as nicely as it should. Apparently, Palm has done something slightly differently with the 700p than they have in other models that I have and KPilot is hanging onto the port longer than it should, even though nothing is happening on it. Hitting the “reset the device connection” button in KPilot’s GUI (and waiting 30 seconds or so… I’ll need to look at that) seems to help, but something is definitely not kosher in Denmark. I’ll try to look at it this weekend, if time allows, on the 3.5 branch.

Don’t even ask me about the KDE 4 branch…  I’m still suffering from deep depression about the state (or lack thereof) of KPilot in trunk.

Wednesday November 21, 2007
by Jason 'vanRijn' Kasper
8 Comments

Better Firefox Themes??

Okay, seriously, I think we could just delete 90% of the firefox themes on addons.mozilla.org. Truly, I am almost physically ill after spending a few minutes looking through them.   And the ones I’ve found on deviantart are out of date and unusable.  Surely, there must be a top-secret repository of really good Firefox 2 themes somewhere, right?  Certainly this can’t be all that there is?

Bah humbug.

You know what?  I think I’d even consider paying some small amount of $cash for something truly beautiful and groundbreaking.

Sunday November 18, 2007
by Jason 'vanRijn' Kasper
18 Comments

MWM looking for Bling/Compiz/Emerald/KDE3 love

Dear Lazyweb,

I would LOVE to have bling on my desktop. I use KDE3, and have been good all year. I think I should be allowed to have bling on my desktop just like all of my GNOME friends.

To this end, I’ve tried running compiz with emerald in my KDE desktop. I can get both compiz and emerald running just nicely and get it all configured the way that I like it. But then whenever I restart X and compiz comes back, it manages to forget half of my keybindings and configuration settings. I don’t think I’m doing anything weird or revolutionary in my settings–just an 8-sided cube with viewport-switching keybindings, ring switching, scale niftiness, animations and other standard-looking stuff.

But for the life of me, I cannot figure out why compiz just manages to forget half of its configuration between restarts. I’m using “ccsm” to configure stuff and for the most part it seems to work just fine (i.e. compiz seems to honor the settings as I’m configuring them). Any idea on what I’m doing wrong? Or is it because I’m using compiz + emerald + KDE? Does anyone in KDE3 desktop land have successful bling with compiz?

Wednesday November 7, 2007
by Jason 'vanRijn' Kasper
7 Comments

KDE NetworkManager workaround

In case anyone else hits this…. In one of the more recent releases of our beloved KDE, code was added to more smoothly integrate with networking. Namely, the attempt is now made to be aware of NetworkManager-initiated network connections, as well as know when NetworkManager doesn’t think it’s connected so as to not keep trying network activities when there might not be a network connection. Excellent idea, honestly.

However (you knew there was one), I have a love/hate relationship with NetworkManager and knetworkmanager. When they work, they work great. When they don’t it’s supremely irritating. Case in point: I’m at a friend’s house. He’s using standard WEP and a non-broadcasted ESSID. I tried all manners of asking NetworkManager nicely for a good 10 minutes to join the network to no avail. In the next 30 seconds, I manually iwconfig’d, ifconfig’d, and dhclient’d my way onto the network and things are working swimmingly. Almost. You see, with the changes we made (see paragraph #1), now KMail and Konqueror, etc., think that I don’t have a network connection because NetworkManager told them I don’t. However, I’ve discovered that I can coax KMail, Konqi, and friends to try using the network connection that I really do have (honestly!) but NetworkManager couldn’t provide for me by doing this on the CLI:

dcop kded networkstatus setNetworkStatus NMNetwork 0

It’s hack, but it seems to do the trick for the time being. I’ll hunt Will down later and ask him how to do this properly…

[UPDATE:]  I caught Will and here’s the real skinny:

Either extend your manual connection script to register a fake network with kded that is online, or shoot the networkstatus system down by disabling it in kcmshell kcmkded.  You can also unregister NMNetwork; the system should be fail-safe.  Or not run knetworkmanager.  The system figures the best connection status, so you can also register your own network.  0 is ‘no information’, 6 is offline, 8 is online in the status enums.

Will rocks, btw.  =;)

Friday November 2, 2007
by Jason 'vanRijn' Kasper
4 Comments

Thinkpad T61 and Iogear 4-port USB KVM Switch

This, the next exciting story in my Adventures With the Thinkpad T61 At Work (TM)  =;)…. So I got a really sweet-looking IOGEAR 4-port USB KVM Switch at work. But when I plugged it into the T61, although the nVidia driver was able to find the external display (auto-detect button thingey), it only gave me 2 options for resolution, the larger of which was 640×480, which obviously is rubbish. So I stumbled across this helpful ubuntu page which gave me the clue I needed:

It would seem that xorg cannot detect the possible resolutions when using the “nvidia” driver. For me, the only resolution I could use was my LCD’s native resolution (1680×1050).

Here’s how you fix this:

1) Make a backup of your /etc/X11/xorg.conf as shown in the previous examples

2) Open /etc/X11/xorg.conf as shown in the previous examples

3) Add the following line to your existing “Screen” section:

Option “UseEdidFreqs” “false”

If all else fails, try running the following command:

sudo nvidia-settings

Under Video Configuration set your resolution and refresh rate, click apply, then save X Config.

I added the UseEdidFreqs as false Option, restarted X, and am now happy once again.  Hope this helps the next poor soul who hits this…  =:)

Thursday November 1, 2007
by Jason 'vanRijn' Kasper
2 Comments

$200 Ubuntu Linux PC Now Available at Wal-Mart

This is pretty darned cool. I bought a $300 desktop from Walmart a few years ago and it’s still running OpenSUSE and serving as a pretty capable desktop machine for the family. Definitely worthwhile to put our FOSS dollars where our mouths are too, imho. Let’s support the companies who are actively putting the software that we think is best out there! =:)

$200 Ubuntu Linux PC Now Available at Wal-Mart | Gadget Lab from Wired.com

$200 Ubuntu Linux PC Now Available at Wal-Mart