Elect-o-meter for linux

Boingboing had a neat post about an “elect-o-meter” that one could hack up — basically a plastic cup that glows red or blue depending on who is winning the election.

I don’t have the necessary hardware though, so I took the code and made a software version:

elect-o-meter

The purple will become more blue or more red depending on who is winning, and then when a winner is declared it will turn fully red or blue. Because the purples are very difficult to discern by eye, I print the actual percentages below.

Here’s the source code. Just run it on a Linux machine and it should work.

Share

I Am Free, and so are you

Jewel Logo

Category: Accessories
Released Aug 9, 2008
Seller: N/A
(c) 2008 Owen Williams
Version: 1.0
24K

The red icon on your Nokia N800 or N810 always reminds you (and others when you show it to them) that you appreciate freedom. It’s a work of art with no hidden function at all.

You are free to install it from the Application Manager from the Extras repository.

You are free to install it with one-click download:

Chinook / Diablo (OS2008)

You are free to download it directly from my website:
i-am-free_1.0-1_armel.deb

You are free to download the sourcecode:
i-am-free_1.0.tar.gz

You are free to open it up, see how it works, make it better, email it to your friends, and do whatever you want.

What else are you free to do?

Share

Converting Varicam 48fps to 24p

Warning, technical video post production post ahead.

A few weeks back we needed to shoot some greenscreen for a show that is being delivered at 23.98fps (aka “24p”). I’d had problems pulling a key in the past with motion blur at that slow framerate (I prefer 30 for TV work), so I suggested we increase the shutter speed in the camera. The DP seemed more comfortable adjusting the framerate, so he suggested we shoot it at 48 and only use every other frame of the footage. I figured I could write a script to do the conversion later.

We shot the footage, and the next week I sat down to write a python program to convert the material to 24 fps. This could have probably been done with final cut or something, but I don’t know that program so I did it the easy way: play around with the frames themselves using an image sequence (ie, a big folder of numbered tif files, each of which represents a frame of footage).

Normally this would be easy, just take every odd-numbered image. But in this case, although we shot at 48fps, the footage is at 60fps. Why? Varicam works like this: the front of the camera (the shutter and CCD) shoot whatever framerate you choose, but the tape recorder in the camera always records 60fps. Even if you shoot 6fps, the varicam writes 60 frames to the tape — 10 of frame 1, 10 of frame 2, etc. So when we shoot 48fps, there are 60 frames per second on the tape, 48 of which are unique and 12 of which are duplicates.

If I am going to convert the footage to 24p, I need to first remove the duplicate frames (60 -> 48 fps), then remove every other frame (48 -> 24). By analyzing the footage frame by frame, I determined that when the varicam shoots 48fps, it uses the following pattern:

0000100001000010001

Where 0 represents a unique frame, and 1 represents a duplicated frame (to fill out to 60fps). This pattern is repeated over and over again throughout the footage. (I only just noticed that the pattern is 19 frames long, not 20 like I’d expect, but looking at the footage that’s what it is.)

My python program goes through an image sequence, finds the pattern of duplicate frames, and then copies every other file that is not a duplicate to a new folder as a new image sequence. It makes the following assumptions: the files are .tif files, and “duplicate frame” means “exactly the same size” (not a bad assumption with digital media and tifs). It’s a little hacky, but looking at the resulting 24fps image sequences I don’t see any stutter or dropped frames.

There are some basic checks in the code so it hopefully won’t overwrite precious data, but I make no guarantees.

Code: 48-to-24.py

Share

Audioscrobbler support in Sonata

As I’ve mentioned before, Sonata is my favorite music player. One shortcoming, however, is that it lacks support for last.fm’s audioscrobbler, which allows music players to automatically submit songs to the service and help build one’s musical profile.

No more: sonata-audioscrobbler.diff

I whipped this up in a couple hours, so be on the lookout for bugs. It’s not so good at reporting bad passwords, so you have to look at the console output for that information. Either you see “BADAUTH” (bad) or “Uploaded 1 tracks successfully” (good). If the Sonata author adds feedback for mpd authentication problems, I’ll hook up to that.

I’ll also update my sonata olpc package to include this patch.

Update: Added a check to ignore songs that don’t have all the metadata that audioscrobbler wants.

Share

De-Crackification

I think I have removed all of the crack from my tag selector. It took about four different branches including experiments with treeviews, comboboxentries, menus, and entrycompletions. The final user experience is not overwhelming for users with few or no tags, and manageable even for users with many tags. Check out the final screencast.

Share

Am I Crack or Not, part 2

I tweaked the new tag selector some more, although I’m getting the feeling that at this point I’m just trying to duplicate a combo box or menu. A few people have suggested I have a box where people can type in a tag name. I don’t want to add another entry box, so I think I might add that functionality to the main search box above the tag list. I still like being able to have a few tags that are always one click away.

Latest tag selector screencast

edit:
Actually the more I look at this, the more it seems like I really just want a regular drop-down menu with a submenu containing all tags. At the bottom of the main part of the menu I could have an item that would spawn a dialog that looks like my current view, and that would be just for selecting and reordering favorites.

Share

PenguinTV optimization

I’ve been going through the crufty and scary ptvDB.py looking for ways to improve performance. Armed with the trust profile and pstats modules, I cut polling time in half by removing redundant and unnecessary database hits.

I then got the idea of generating a print statement every time I hit the DB, so I can see exactly what the database is doing during regular operation.

The result is not always pretty:

Basic article read:

SELECT title, creator, link, description, feed_id, date FROM entries WHERE id=? (69443,) ok
SELECT id,entry_id,url,file,download_status,viewed,length,mimetype FROM media WHERE entry_id = ? (69443,) ok
SELECT read FROM entries WHERE id=? (69443,) ok

Ok that’s fine, we get the entry, any associated media, and then the read state.

What about an unread entry?
SELECT title, creator, link, description, feed_id, date FROM entries WHERE id=? (67523,) ok
SELECT id,entry_id,url,file,download_status,viewed,length,mimetype FROM media WHERE entry_id = ? (67523,) ok
SELECT read FROM entries WHERE id=? (67523,) ok
UPDATE entries SET read=? WHERE id=? (1, 67523) ok
UPDATE media SET viewed=? WHERE entry_id=? (1, 67523) ok
SELECT read FROM entries WHERE id=? (67523,) ok
SELECT id,entry_id,url,file,download_status,viewed,length,mimetype FROM media WHERE entry_id = ? (67523,) ok
SELECT title, creator, link, description, feed_id, date FROM entries WHERE id=? (67523,) ok
SELECT id,entry_id,url,file,download_status,viewed,length,mimetype FROM media WHERE entry_id = ? (67523,) ok
SELECT read FROM entries WHERE id=? (67523,) ok
SELECT feed_pointer,description FROM feeds WHERE id=? (233,) ok
SELECT id,title,fakedate FROM entries WHERE feed_id=? ORDER BY fakedate DESC (233,) ok
SELECT id FROM entries WHERE feed_id=? (233,) ok
SELECT feed_pointer FROM feeds WHERE id=? (233,) ok
SELECT pollfail FROM feeds WHERE id=? (233,) ok
SELECT feed_pointer FROM feeds WHERE id=? (233,) ok
SELECT read FROM entries WHERE feed_id=? (233,) ok
SELECT id FROM feeds WHERE feed_pointer=? (233,) ok

Oops. It’s whacking the database three times for the entry data, and updates the whole feed as well. Time to figure out what I’m doing wrong!

Share

“It’s not Citizen Kane, it’s Snakes on a Plane”

This jewel was uttered by a guy sitting near me at the midnight showing of Snakes on a Plane at AMC Loews Boston Common Theater yesterday. Fifteen minutes before showtime, he was on the phone trying to convince a friend to come to the theater. It’s a shame his friend didn’t show.

That little couplet serves as the perfect review of Snakes on a Plane. It is also a no-contest rebuttal to any criticism of the movie. Do the first fifteen minutes of the movie exist only to get everyone on Pacific Air Flight 121 as fast as possible? Yes, but even that was a little long for some in the audience. Are some of the characters shallow, and are some of the actors really bad? Of course! Do the effects pale in comparison to Pirates of the Caribbean? Damn straight!

It is a little cheesy, a little scary, and quite a bit funny, all in the right proportions. Most importantly, it does not take itself too seriously. “Snakes” is a good B-movie, something I feel like I haven’t seen in a while. When was the last time you saw a really bad police interrogation scene?

Should you see Snakes on a Plane? Yes, but if you weren’t in Theater 16 on Thursday night you’ve already missed the greatest showing there will ever be of this movie. I invited my friend Mike to the show, and he brought a printout of the Snakes on a Plane Participation Script. Well before showtime, he helped the audience learn the key lines: anytime the asian bad guy finishes a sentence, yell “…in bed!”; anytime a sentence ends in “snakes,” yell “motherfucking snakes!”; anytime Samuel L Jackson yells at someone, add “...bitch!” for emphasis; etc. It was a little like a Rocky Horror Screening, except that nobody had seen the movie yet. So when the entire theater found out that adding “in bed” actually works for damn near everything the asian guy says, it was hilarity topped with the joy of discovery.

I wouldn’t trust any reviewer who wasn’t in a theater with the electric atmosphere and audience participation I experienced last night. The story of SoaP’s development and production has been one of collaboration between the filmmakers, the fans, and especially Sam himself. For this movie to work that collaboration must extend to the screenings as well. Putting the burden of the entertainment on the film itself is a dereliction of duty by the audience. So print out the wiki, bring some rubber snakes, and do your part!

Share