Binary Static

Interleaving two PDF files…

Posted in Applications, Hacking, Linux by Chris on October 17, 2010

Lightbulb…with no scripting required.  You’ll need the pdftk package though.  Say you’ve got a PDF file that has a two-sided layout and you want to trim the pages.  You could do this with pdfnup — however, your file may cut off from the even pages what it adds to the odd ones.  What now?  The solution is simple:

1. Use pdftk to split the file in even and odd pages seperately:

pdftk in.pdf cat 1-endeven output out.even.pdf
pdftk in.pdf cat 1-endodd output out.odd.pdf

2. Now would be the time to apply some pdfnup trimming magic to the two new files.

3. Use pdftk to burst these two files into single pages:

pdftk out.odd.pdf burst output %04d_A.pdf
pdftk out.even.pdf burst output %04d_B.pdf

4. Use pdftk to merge the pages back into one file, e.g.:

pdftk *.pdf cat output out.pdf

The important point here lies in step 3 when appending A or B to the odd and even page file names, because this allows glob sorting the pages like 0001_A.pdf 0001_B.pdf 0002_A.pdf 0002_B.pdf and so on.  I can’t believe I started to write a script before I realized how to solve this the simple way…

Tagged with: , , ,

Comfortably ripping CDs in the Linux console

Posted in Linux by Chris on December 2, 2009

Since I’m still converting my CD-Collection to listen to them on my iPod, I spent some time figuring out the easiest way to do this — in the background, with reasonable audio quality, and of course on Linux. My workflow now comes down to this:

  1. using the abcde script to rip the cd, some customizations apply
  2. using MusicBrainz through picard for tuning folder hierarchy and tags
  3. using Amazon’s API to download the cover files

This might be a bit more work than other approaches, but I get kick-ass audio files, clean tags and file names. This is my ~/.abcde.conf:

OUTPUTTYPE=mp3:" -V2 --vbr-new -q0 --lowpass 19.7 -b96"
mungefilename ()
echo "$@" | sed s,:,\ -,g | tr -d \'\"\?\[:cntrl:\]

Your device is probably named differently. The OUTPUTTYPE parameter sets the settings for lame. I chose a variable bitrate and basically cut off everything the ear can’t hear. The OUTPUTFORMAT parameter names and sorts the files into a iTunes-style hierarchy. I tweaked the mungefile() method to get Windows-style filenames, i.e. I want whitespace in my filenames.

I run abcde from a sandbox folder on my hard drive. It’s easy to put it in the background by starting it with screen. Having collected new music, I filter the whole stuff through picard to get top-notch MP3 tags. What picard can’t find I’ll add to the MusicBrainz database myself from the original CD.

As I use boxee to play and display my audio files on my media box, I want neat high-resolution cover images in each folder. I wrote a short python script to retrieve the covers from Amazon via their store API. Currently, I’m trying to add a GUI, which allows to scan whole music collections and provide missing or wrong images in batch mode. Once I’m done, I’m going to roll this into a Ubuntu package and distribute it.

Tagged with: , ,