#!/usr/bin/perl -w
#
# mkogg.pl - this program converts .flac files in directory to .ogg
#
# This program accepts no arguments or parameters - the input
# filenames are read from the current directory.
#
# Filenames are assumed to have have the following data:
#
# artistname-albumname-trackno-songtitle.flac
#
# Each of the fields separated by '-' (artistname, albumname,
# trackno, and songtitle) contain underscores ('_') where the
# spaces should be. No special characters are supported in
# the input (.flac) file names, so set up the ripping and
# flac encoding appropriately.
#
# The FLAC decoding and OGG encoding operations are spawned as
# child processes to this process. There should probably be some
# sort of monitoring here that would reap the child PIDs if
# something goes wrong.
#
# This software depends on the FLAC decoder flac(1) and the OGG
# encoder oggenc(1) being installed and available in the path.
#
# Revision History:
# 2005-10-30: pdwilso@gmail.com - Initial version
# 2005-10-31: pdwilso@gmail.com
# - Corrected really heinous error that was over-
# writing the source .flac files.
# - Corrected syntax error in code that collects
# child PID into @children array.
# - Added $QUIET and $DEBUGGING declarations.
#
$QUIET=0;
$DEBUGGING=0;
opendir(DH, ".") || die "could not open current working dir : $!";
@flacs = grep { chomp, /\.flac$/ } readdir DH;
closedir DH;
@children = ();
unless ($QUIET) {
print "Found ".scalar(@flacs)." FLAC files...\n";
}
foreach my $flac (@flacs) {
if (my $pid=fork) {
push @children, $pid;
} else {
my ($artist,$album,$track,$title) = split(/-/,$flac);
$title=~s/\.flac$//;
foreach my $s ($artist,$album,$title) {
$s=~s/_/ /g;
$s=~s/\W([a-z])/ \U$1/g;
$s=~s/^([a-z])/\U$1/;
}
my $ofile = $flac;
$ofile =~ s/flac$/ogg/g;
my $params=
"-a '$artist' ".
"-t '$title' ".
"-l '$album' ".
"-o $ofile ".
"-N $track";
unless ($QUIET) {
print "Converting $flac to\n $ofile ...\n";
}
if ($DEBUGGING) {
"COMMAND: ",
"flac -s -d -c $flac | oggenc -Q $params -\n";
}
my $output= `flac -s -d -c $flac | oggenc -Q $params -\n`;
unless ($QUIET) {
print "$ofile done.\n";
}
exit;
}
}
2004/09 2005/03 2005/04 2005/05 2005/06 2005/07 2005/08 2005/09 2005/10 2005/11 2006/01 2006/02 2006/04 2006/05 2006/06 2008/01
Subscribe to Posts [Atom]