]>
diplodocus.org Git - flac-archive/blob - fa-mp3cd
5 B<fa-mp3cd> - Make Universal Disk Format image of MP3 files from FLAC files
9 B<fa-mp3cd> [B<-d> I<work-directory>] [B<-o> I<image-file>] [B<-V> I<VOLI>] I<file> [...]
13 Each I<file> argument is a single-track[1] FLAC file to be transcoded to MP3
14 and stored in the UDF image. By default, place MP3 files in directories named
15 after the album title. Change with B<-dirname> options tracks after the
16 B<-dirname> go into that dirname. Restore default with B<-diralbum>.[2]
18 B<fa-mp3cd> starts by validating all input files and planning the layout, then
19 looking into I<work-directory> for any files not in the plan, exiting with an
20 error if any are found. If files exist that are in the plan, assume this is a
21 rerun after crash and resume starting at the last file written. E.g. if
22 writing 100 files and crash after finishing file 98 but before starting file
23 99, go ahead and rewrite file 98.
30 Still considering restoring whole-disc FLAC file support.
41 =item B<-d> I<work-directory>
43 Path of the directory to write the UDF layout into. Default is the
46 =item B<-o> I<image-file>
48 Path of file to write UDF image to. No default: if not specified, B<fa-mp3cd>
49 prepares the I<work-directory> but makes no image.
53 Passed through to B<mkisofs(1)>, which says:
57 Assume files in I<work-directory> are up to date rather than assuming resume
62 Run B<mkisofs(1)> to print out the estimated size (in kilobytes) of the image
63 as well as how much remains of the 650 MB allowed on CD-ROM.
67 Specifies the volume ID (volume name or label) to be written into the master
68 block. There is space on the disc for 32 characters of information.
72 Some systems may use this volume ID as the name of a mount point.
78 Written by Eric Gillespie <epg@pretzelnet.org>.
82 package epg
::flac
::archive
::mp3
::cd
;
88 use lib
$FindBin::Bin
;
92 epg
::flac
::archive
::tags-
>import(
103 mangle_for_file_name
(
105 (map { two_digits
($_) } @{$tags->{DISCNUMBER
} // []}),
106 (map { two_digits
($_) } @{$tags->{TRACKNUMBER
} // []}),
108 @{$tags->{VERSION
} // []},
109 @{$tags->{PARTNUMBER
} // []},
120 tags
=> {track_tags
($tags)},
122 filename
=> filename
($tags),
123 dir
=> join('/', $workdir, mangle_for_file_name
(@{$tags->{ALBUM
}})),
129 map { {plan_flac
($workdir, @$_)} } @_
132 # if @layout is partially on disk, return the portion that remains to be written
133 sub check_directory
{
135 my $workdir_files = shift;
140 my %workdir_files = map { ($_, 1) } @$workdir_files;
141 for my $mp3 (@layout) {
142 my $path = join('/', $mp3->{dir
}, $mp3->{filename
});
143 if (exists($workdir_files{$path})) {
144 delete($workdir_files{$path});
147 if (defined($last)) {
148 push(@remaining, $last);
151 push(@remaining, $mp3);
154 defined($last) && push(@remaining, $last);
155 if (%workdir_files > 0) {
156 die("unexpected files in $workdir: ", join(' ', sort(keys(%workdir_files))))
163 my $workdir = '.'; # TODO
164 my $imagefile; # TODO
166 $workdir, $imagefile, @_
171 # If we come across stupid file names embedded newlines, check_directory will complain about them.
172 open(my $fh, '-|', 'find', $path, '!', '-type', 'd') || die("find $path ! -type d: $!");
180 die("find $path ! -type d exited $?")
182 die("close(find $path ! -type d): $!")
188 my ($workdir, $imagefile, @flac_files) = read_args
(@_);
190 # -no-resume would mean skipping preparing the work directory at all.
191 # So that's probably not the right name for the flag.
192 my @layout = check_directory
(
194 find_files
($workdir),
197 map { ["$_", read_tags_metaflac
($_)] } @flac_files,
199 for my $mp3 (@layout) {
200 say('mkdir -p ' . $mp3->{dir
});
201 epg
::flac
::archive
::mp3
::flac2mp3
(join('/', $mp3->{dir
}, $mp3->{filename
}), $mp3->{flac
}, $mp3->{tags
});
205 if (defined($imagefile)) {
206 # Have to redirect it; won't accept -o with -reproducible-date!
207 #'-o', quote($imagefile)
208 @output = ('>', quote
($imagefile));
210 # "Print estimated filesystem size in multiples of the sector size (2048 bytes)"
211 # Overhead seems to be under 1MB so shoot for total of 649 MB of files.
212 @output = ('-print-size');
214 # If I cared for fully reproducible image, set all file and directory timestamps:
215 # touch -d `git log -1 '--format=%cd' '--date=format:%FT%T'`
219 #'-reproducible-date', `date '+%Y-%m-%d %H:%M:%S %z'`,
220 #'-reproducible-date', `git log -1 '--format=%ai'`,
221 #'-reproducible-date', quote('2022-03-11 23:37:11 -0600'),
223 '-full-iso9660-filenames',