#!/usr/bin/perl # radiorec -- record wav file from line input, # and convert it to 64K and 32K Mono MP3 file # usage: radiorec -l -f # where: specifies recording duration in minutes, # specifies prefix for filename of result mp3 data # (path name is accepted, too). Date and time of the recording will # be added to the filename automatically. # # Copyright (c) 2000 by Hiroshi Nakamura # 2002.12.13 ALSAドライバを0.5から0.9にアップにともない$commandline変更 # require "getopt.pl"; $encoder = "/usr/bin/gogo"; $wavrec = "/usr/bin/arecord"; $bash = "/bin/bash"; &Getopt('fl'); # f for filename, l for record length if ($opt_f =~ /[^a-zA-Z0-9\/\-\_]/ ) { $recfile = "radio"; } else { $recfile = $opt_f; } if ($opt_l <= 0) { die "ERROR: Please specify length of recording in minutes.\n"; } else { $minutes = $opt_l; } $seconds = $minutes * 60; ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(); $year = $year + 1900; # y2k $mon = $mon + 1; $timestring = substr("0000$year", -4) . substr("00$mon", -2) . substr("00$mday", -2) . substr("00$hour", -2) . substr("00$min", -2); $recfile = $recfile . $timestring; $commandline = "$wavrec -d $seconds -t wav -r 44100 -f S16_LE $recfile.wav \&\>/dev/null;" . "$encoder -b 32 -silent $recfile.wav $recfile" . "_32K.mp3 2\>\>/tmp/radiorec.log;" . "$encoder -silent -b 64 -delete $recfile.wav $recfile" . "_64K.mp3 2\>\>/tmp/radiorec.log"; exec $commandline;