iPod::Squish - Convert songs on an iPod in place using lame or FFmpeg::Command.
use iPod::Squish; my $squisher = iPod::Squish->new( volume => "/Volumes/iPod Name" target_bitrate => 128, ); $squisher->run;
This module uses lame or FFmpeg::Command to perform automatic conversion of songs on an iPod after they've been synced.
Since most headphones are too crappy to notice converting songs to a lower bitrate is often convenient to save size.
Only files with a bitrate over
target_bitrate will be converted.
Currently only MP3 files will be converted and the output format is MP3 as well. AAC support would be nice, see "TODO".
A tip to sync more data than iTunes is willing is to do it in several steps by using a smart playlist and limiting the number of songs in the playlist by the number of free megabytes on the player. Then you can run the squishing script, and repeat ad nauseum.
The mount point of the iPod you want to reencode.
The bitrate to encode to.
Only songs whose bitrate is higher than this will be encoded.
lame command directly instead of FFmpeg::Command.
Defualts to true if
lame is in the path, because it's more flexible than lame through ffmpeg.
Note that using lame is generally slower for the same
target_bitrate because of the
-h flag passed to lame.
The number of parallel lame instances to run. Defaults to 2. Useful for multi processor or multi core machines.
Do the conversion by recursing through the iPod's music directory and running
process_file for each file (possibly in parallel, see
Attempt to convert the file, and if conversion succeeds replace the original with the new version.
The file will only be converted if its an MP3.
Does the actual encoding/move of the file.
I'm not quite sure how to specify varible bitrate for
ffmpeg. Should look into that.
m4a type AAC files (I don't think ffmpeg allows this, but I'm not quite sure). Encoding to AAC definitely is supported.
Check if an iPod will swallow files in a format different than the name/library entry implies.
If not, try to use rewrite library entries, as long as this doesn't affect synchronization.
Perhaps look at Mac::iPod::DB for details.
Using an app called Lingon (http://lingon.sourceforge.net/) you can easily create an agent that will run every time a disk is mounted.
My entry is:
nice /usr/local/bin/perl -I /Users/nothingmuch/Perl/iPod-Squish/lib /Users/nothingmuch/Perl/iPod-Squish/script/isquish
Because the script loops until no more songs are converted, and copying is likely faster than encoding it should generally Just Work™ automatically.
Make sure you have lame or ffmpeg in the path, and if you want lame to STFU then set TERM to something as well.
This can be done by using
env TERM=xterm-color PATH=...
to actually run the script.
This module is maintained using Darcs. You can get the latest version from http://nothingmuch.woobling.org/code, and use
darcs send to commit changes.
Yuval Kogman <email@example.com>
Copyright (c) 2008 Yuval Kogman. All rights reserved This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.