Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
#! /usr/bin/perl # created by Daniel R. Anderson (2005) # trompelamort KOALA =~ s/marsupial/@/; # this code protected under the GPL use strict; use warnings; # VARIABLES # these variables are needed to process the files my $filelist = shift @ARGV; my $genre = shift @ARGV; my $artist = shift @ARGV; my $album = shift @ARGV; my $encoding = (shift (@ARGV)) || "mp3"; # quality for the ogg encoder on a scale of 1 to 10 # 10 being best my $ogg_quality = 10; # quality for the mp3 encoder (lame) on a scale of 0 to 9 # 0 being the best # a quick and dirty test says that you do not want to use 0 # a 9 seems to be CD quality sound # since you can't get better than CD quality sound # stick with the 9 my $mp3_quality = 9; # shall we print debug messages? my $debug = 1; #error checking unless ($filelist and $artist and $album) { die ("Usage: ./ filelist artist album\n"); } elsif (not (-e $filelist)) { die ("Filename $filelist does not exist!\n"); } elsif (not (-r $filelist)) { die ("We do not have sufficient permission to read $filelist\n"); } print "Using $filelist as file list.\n"; # open the file list for reading open ("FILELIST", "< ./$filelist") or die ("Cannot open $filelist because $!\n"); # grab all the filenames my @filenames = <FILELIST>; if ($debug) { print "DEBUG INFO:\n\n"; print "filenames:\n"; my @filecopy = @filenames; while (@filecopy) { print (shift @filecopy); } } # my $filename = <FILELIST>; # while ($filename) { # $filename = chomp $filename; # print "filename $filename\n"; # if ($filename) { # push @filenames, $filename; # } # $filename = <FILELIST> # } # clean up our mess close (FILELIST) or die ("Cannot close FILELIST due to $!\n"); # we've got the filenames, set up the encodings my $encoder = ""; my $switches = ""; # set up the data we need to encode the files if ($encoding eq "ogg") { # encode the wav files using the Ogg Vorbis encoding $encoder = "oggenc"; $switches = "--genre \"$genre\" --tracknum \"??track??\" --title \"? +?trackname??\"" . " --album \"$album\" --artist \"$artist\" --quality=$ogg_quali +ty -o \"??output_file??.ogg\" " . "\"??input_file??\""; } elsif ($encoding eq "mp3") { # encode the wav files using the mp3 encoding # make use of LAME # first convert the quality from oggenc to lame $encoder = "lame"; $switches = "-q $mp3_quality \"??input_file??\" \"??output_file??.mp +3\" "; } else { die ("We should never get here!"); } unless ($encoder) { die ("No encoder specified!\n"); } elsif (not $switches) { die ("No switches specified!\n"); } if ($debug) { print "DEBUG INFO\n\n"; print "Encoder: $encoder\n"; print "Switches: $switches\n\n"; } my $counter = 1; while (@filenames) { my $filename = shift (@filenames); chomp $filename; next unless $filename; print "Encoding filename $filename\n"; my $tempcounter = $counter; if ($counter < 10) { $tempcounter = '0' . $counter; } my $input_file = "track" . $tempcounter . ".cdda.wav"; my $output_file = $tempcounter . ". $artist -- $album -- $filenam +e"; # although an array/while-loop may seem superfluous, # it is important because it allows for multiple # commands... i.e. encode this file # then move it to a prespecified directory. my @to_execute = ( "$encoder $switches", ); while (@to_execute) { my $execute_me = shift (@to_execute); $execute_me =~ s[\?\?output_file\?\?][$output_file]; $execute_me =~ s[\?\?input_file\?\?][$input_file]; $execute_me =~ s[\?\?track\?\?][$tempcounter]; $execute_me =~ s[\?\?trackname\?\?][$filename]; next unless $execute_me; if ($debug) { print "DEBUG INFO:\n\n"; print "Executing command:\n$execute_me\n\n"; } `$execute_me`; } $counter++; }

In reply to Automatically Encode Ogg / MP3s by Vautrin

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2022-05-21 00:50 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (76 votes). Check out past polls.