Handy scripts!

So, as proof that I still exist, I’m posting some scripts that I’ve used as of late. I’m sure they’re simplistic, flawed, and trivial to replicate. However, they’re what I needed, so I assume there are other people out there who could use them, too.

First, I have “distributer.rb.” It’s a ruby program that keeps an arbitrary number of programs running in parallel. (Download it here: distributer.rb)

Syntax is ./distributer.rb [number of procs] [command] [list of arguments to substitute for %VAR in [command]]

ex. ./distribute.rb 8 “./transcode_to_h264 ‘%VAR’ ‘h264_version_%VAR’” $(find -type f -regex “.*\.[Aa][Vv][Ii]“) # this will find all .AVIs within this directory and its subdirectories and always keep eight processes of ./transcode_to_h264 running in parallel on different files.

Now, for those of you who are giant CLI/console and music quality geeks, I offer RiPPER/wRaPPER (which looks nicer with the two words stacked on top of each other). (Download it here: ripper-wrapper.rb)

It rips music CDs to FLAC using cdparanoia and tolerates no errors in copying.

Now, if we music snobs (read: people who feel the savings of a few bits is a waste relative to the knowledge that our archives are complete) want to give our music to people with non-FLAC music players, we’ll want to convert it to mp3. Note that the output of this will be mixed in with the FLAC files. If you want to move the output or delete the input, well, c’mon add the appropriate line… (Download it here: convert-flac-to-mp3-in-place.sh)

Syntax is pretty trivial: ./convert-flac-to-mp3-in-place.sh [FLAC file]

I’ll add to this list as I find useful scripts that don’t embarrass me and as I clean up and document those I have.

Here are a few one-liners that I use often for video:

  • For people who have an iAudio A2 and want to convert videos to be as small as possible and but not visibly transcoded: mencoder -vf pp=ac,scale=-3:272:0 -oac mp3lame -af resample=44100:0:2 -ovc xvid -xvidencopts autoaspect:bitrate=512:noqpel:nogmc -ofps 24 -o “a2_version_$1.avi” “$1″
  • For converting video to H.264: mencoder $1 -oac copy -ovc x264 -x264encopts subq=6:4×4mv:8×8dct:me=3:frameref=5:bframes=3:b_pyramid:weight_b -o h264_$1.avi