]>
diplodocus.org Git - flac-archive/blob - flac2mp3
7 B<flac2mp3> - transcode FLAC file to MP3 files
15 B<flac2mp3> transcodes the FLAC file I<file> to MP3 files. I<file> is
16 the kind of FLAC file B<fa-flacd> generates. That is, it contains a
17 cue sheet, one TITLE tag per track listed therein, and ARTIST, ALBUM,
28 return sprintf('%02d:%02d.%02d', @_);
35 open(F
, '-|', 'metaflac', '--export-cuesheet-to=-', $fn);
37 /INDEX 01 (\d\d):(\d\d):(\d\d)$/ or next;
38 push(@l, [$1, $2, $3]);
43 my $arg = ["--skip=" . tformat
(@{$l[$i]})];
46 if ($next->[2] == 0) {
47 if ($next->[1] == 0) {
48 push(@$arg, '--until=' . tformat
($next->[0] - 1, 59, 74));
50 push(@$arg, '--until=' . tformat
($next->[0], $next->[1] - 1,
54 push(@$arg, '--until=' . tformat
($next->[0], $next->[1],
64 # Return the ARTIST, ALBUM, and DATE tags followed by the TITLE tags
75 open(TAGS
, '-|', 'metaflac', '--export-vc-to=-', $fn)
76 or die("open(metaflac --export-vc-to=- $fn): $!");
80 ($tag, $value) = split(/=/, $_, 2);
89 push(@titles, $value);
92 close(TAGS
) or die("close(metaflac --export-vc-to=- $fn): $?");
94 return ($artist, $album, $date, @titles);
104 my $skip_arg = shift;
105 my $until_arg = shift;
108 # We'll be putting these in single quotes, so we need to escape
109 # any single quotes in the filename by closing the quote ('),
110 # putting an escaped quote (\'), and then reopening the quote (').
111 for ($fn, $title, $artist, $album, $date) {
115 $outfile = sprintf("$artist ($album) \%02s $title.mp3", $track);
116 $outfile =~ s/\//_
/g
;
120 system("flac -cd $skip_arg $until_arg '$fn' | lame --preset standard --tt '$title' --ta '$artist' --tl '$album' --ty '$date' --tn $track - '$outfile'");
124 my $fn = shift or pod2usage
();
125 my @args = get_decode_args
($fn);
126 my ($artist, $album, $date, @titles) = get_tags
($fn);
128 for my $i (0..$#titles) {
129 flac2mp3
($fn, $titles[$i], $artist, $album, $date, $i + 1,
139 Written by Eric Gillespie <epg@pretzelnet.org>.
144 # cperl-indent-level: 4
145 # perl-indent-level: 4
146 # indent-tabs-mode: nil
149 # vi: set tabstop=4 expandtab: