PDA

View Full Version : Making mp3 copies of my flac music collection



John Gorst
2005-01-16, 10:34
I am trying to search for a solution for the task below - but have spent
all day with no avail.

I wish to make mp3 copies of all my flac music collection to aid in
downloading my music onto portable music players.

My music is stored on a linux server running slimserver.

The flac files are stored as one file per track, in directories
Artist-->Album-->track.flac

I wish to automatically be able to convert my whole flac music directory
to mp3, storing the mp3s in a different location. Maintating the tags is
a must, and maintaining the directory tree is desireable.

The software can be either windows or linux (as I can access the flac
files over a samba share). A bonus would be if it detected if it has
already converted the track previously - but this would be the icing on
the cake!

Does anyone else so a similar thing in a simple automated fashion?

I know I can setup my cd ripping software to make flac and mp3 copies,
but that does not help convert the 100 flac albums already ripped!

Thanks for any help!

Marc Sherman
2005-01-16, 11:08
John Gorst wrote:
>
> The flac files are stored as one file per track, in directories
> Artist-->Album-->track.flac

You've got a linux box, right?

Your best bet is probably to write yourself a shell script using find,
lame, and some command line id3 tagger such as id3v2.

- Marc

Jules Taplin
2005-01-16, 11:38
Indeed. Pretty simple stuff.

John - Something like the below does the bulk of what you'd require.
Simply tweak the $inputdir and $outputdir to be where you want them to
be... and set $BITRATE to be what you wanted.

Doesn't deal with moving tags over... but other than that... I'd say
it's close to what's required. It won't try to reprocess anything that's
already existing, either.

Less than 10 minutes work... and that includes the testing. That's why
command-line based systems will always be a more productive place to be
than a world where people think tools come with a GUI and drop-down
windows ;)


-- Jules

PS. Yes, real perl programmer types - I know that's ugly. Backticking
out to do finds, when I could be using opendir() and recursing is bad
manners, not to mention the fact that I don't check for all manners of
bad behaviour (don't check for symlinks, or appropriate privileges, and
you can probably blow it up a million ways).

#!/usr/bin/perl -w

$inputdir ="/tmp/flacs/";
$outputdir = "/tmp/mp3s/";

$BITRATE = "160";
chdir("$inputdir");
@output1 = `find . -name \\*.flac`;
@output2 = `find . -name \\*.flc`;

@output = (@output1, @output2);

foreach $filename (@output)
{
chomp $filename; chomp $filename;
if(-e $outputdir.$filename.".mp3")
{
print "$filename already converted... skipping\n";
next;
}
$dirname = `dirname $filename`; chomp $dirname;
mkdir($outputdir.$dirname) unless(-d $outputdir.$dirname);
print "Processing: $filename\n";
system("flac -dcs $filename | lame -b $BITRATE -
$outputdir".$filename.".mp3");
}

Marc Sherman wrote:

> John Gorst wrote:
>
>>
>> The flac files are stored as one file per track, in directories
>> Artist-->Album-->track.flac
>
>
> You've got a linux box, right?
>
> Your best bet is probably to write yourself a shell script using find,
> lame, and some command line id3 tagger such as id3v2.
>
> - Marc
>

Robert Wallace
2005-01-16, 13:40
John,

The foobar2000 (Windows) player will do very nice conversions from FLAC
to MP3 (or almost anything that can run from the command line), but it's
only automatic in the sense that it will convert everything it its
current playlist using its diskwriter component. The settings on the
component let you select the command line encoder (for MP3, I use lame)
and its settings. It preserves tags, writing the FLAC tag into and
ID3v1 or v2 MP3 tag. It says it will create subdirectories during the
MP3 creation process, but I haven't tried to do that, so I'm not sure if
it does that the way you want. It's free, which is another nice thing.
It's also got a ton of features, and has replaced WinAmp as my desktop
player.

It's fast enough on my machine that I just drag the tunes I want on my
hand-held player into the foobar playlist, select them all, right-click
and select Convert. In a few minutes, they're ready to load into my
hand-held.

Jules is right - command-line rules. But there's nothing wrong with
free software if it does what you want.

Robert

Jules Taplin wrote:

> Indeed. Pretty simple stuff.
>
> John - Something like the below does the bulk of what you'd require.
> Simply tweak the $inputdir and $outputdir to be where you want them to
> be... and set $BITRATE to be what you wanted.
>
> Doesn't deal with moving tags over... but other than that... I'd say
> it's close to what's required. It won't try to reprocess anything
> that's already existing, either.
>
> Less than 10 minutes work... and that includes the testing. That's why
> command-line based systems will always be a more productive place to
> be than a world where people think tools come with a GUI and drop-down
> windows ;)
>
>
> -- Jules
>
> PS. Yes, real perl programmer types - I know that's ugly. Backticking
> out to do finds, when I could be using opendir() and recursing is bad
> manners, not to mention the fact that I don't check for all manners of
> bad behaviour (don't check for symlinks, or appropriate privileges,
> and you can probably blow it up a million ways).
>
> #!/usr/bin/perl -w
>
> $inputdir ="/tmp/flacs/";
> $outputdir = "/tmp/mp3s/";
>
> $BITRATE = "160";
> chdir("$inputdir");
> @output1 = `find . -name \\*.flac`;
> @output2 = `find . -name \\*.flc`;
>
> @output = (@output1, @output2);
>
> foreach $filename (@output)
> {
> chomp $filename; chomp $filename;
> if(-e $outputdir.$filename.".mp3")
> {
> print "$filename already converted... skipping\n";
> next;
> }
> $dirname = `dirname $filename`; chomp $dirname;
> mkdir($outputdir.$dirname) unless(-d $outputdir.$dirname);
> print "Processing: $filename\n";
> system("flac -dcs $filename | lame -b $BITRATE -
> $outputdir".$filename.".mp3");
> }
>
> Marc Sherman wrote:
>
>> John Gorst wrote:
>>
>>>
>>> The flac files are stored as one file per track, in directories
>>> Artist-->Album-->track.flac
>>
>>
>>
>> You've got a linux box, right?
>>
>> Your best bet is probably to write yourself a shell script using
>> find, lame, and some command line id3 tagger such as id3v2.
>>
>> - Marc
>>

John Gorst
2005-01-16, 15:10
Robert Wallace wrote:
> John,
>
> The foobar2000 (Windows) player will do very nice conversions from FLAC
> to MP3 (or almost anything that can run from the command line), but it's
> only automatic in the sense that it will convert everything it its
> current playlist using its diskwriter component. The settings on the
> component let you select the command line encoder (for MP3, I use lame)
> and its settings. It preserves tags, writing the FLAC tag into and
> ID3v1 or v2 MP3 tag. It says it will create subdirectories during the
> MP3 creation process, but I haven't tried to do that, so I'm not sure if
> it does that the way you want. It's free, which is another nice thing.
> It's also got a ton of features, and has replaced WinAmp as my desktop
> player.
>
> It's fast enough on my machine that I just drag the tunes I want on my
> hand-held player into the foobar playlist, select them all, right-click
> and select Convert. In a few minutes, they're ready to load into my
> hand-held.
>
> Jules is right - command-line rules. But there's nothing wrong with
> free software if it does what you want.

FooBar does exactly what I want with a little bit of pursuasion!

The creation of subdirectories requires a little bit of 'RTFM' as there
are more possibilities thatn meet the eye!

I would agree that the command line rules - but I havent quite got there
yet!
Cheers

John Gorst
2005-01-16, 16:47
Robert Wallace wrote:
> John,
>
> The foobar2000 (Windows) player will do very nice conversions from FLAC
> to MP3 (or almost anything that can run from the command line), but it's
> only automatic in the sense that it will convert everything it its
> current playlist using its diskwriter component. The settings on the
> component let you select the command line encoder (for MP3, I use lame)
> and its settings. It preserves tags, writing the FLAC tag into and
> ID3v1 or v2 MP3 tag. It says it will create subdirectories during the
> MP3 creation process, but I haven't tried to do that, so I'm not sure if
> it does that the way you want. It's free, which is another nice thing.
> It's also got a ton of features, and has replaced WinAmp as my desktop
> player.
>
> It's fast enough on my machine that I just drag the tunes I want on my
> hand-held player into the foobar playlist, select them all, right-click
> and select Convert. In a few minutes, they're ready to load into my
> hand-held.
>
> Jules is right - command-line rules. But there's nothing wrong with
> free software if it does what you want.
>
> Robert

Just about perfect apart from one thing!
If a file already exists it asks you if you want to overwrite, overwrite
all or skip. However it does not give you a 'skip all' option which is
very annoying as it means it converts files even if they have been
converted previously hence wasting /a lot/ of time!

Jules Taplin
2005-01-16, 17:21
Hehe.

Well, John.... consider the script a gift. And as with all good free
software... take it, and extend it to do what you need. Then give it
back. That way, everybody benefits *grin*.


-- Jules


John Gorst wrote:

> Robert Wallace wrote:
>
>> John,
>>
>> The foobar2000 (Windows) player will do very nice conversions from
>> FLAC to MP3 (or almost anything that can run from the command line),
>> but it's only automatic in the sense that it will convert everything
>> it its current playlist using its diskwriter component. The settings
>> on the component let you select the command line encoder (for MP3, I
>> use lame) and its settings. It preserves tags, writing the FLAC tag
>> into and ID3v1 or v2 MP3 tag. It says it will create subdirectories
>> during the MP3 creation process, but I haven't tried to do that, so
>> I'm not sure if it does that the way you want. It's free, which is
>> another nice thing. It's also got a ton of features, and has
>> replaced WinAmp as my desktop player.
>>
>> It's fast enough on my machine that I just drag the tunes I want on
>> my hand-held player into the foobar playlist, select them all,
>> right-click and select Convert. In a few minutes, they're ready to
>> load into my hand-held.
>>
>> Jules is right - command-line rules. But there's nothing wrong with
>> free software if it does what you want.
>
>
> FooBar does exactly what I want with a little bit of pursuasion!
>
> The creation of subdirectories requires a little bit of 'RTFM' as
> there are more possibilities thatn meet the eye!
>
> I would agree that the command line rules - but I havent quite got
> there yet!
> Cheers
>
>

Jules Taplin
2005-01-16, 17:29
nyuk nyuk... perl scripting wins again *grin*.

Ok. I'll get off my high horse now. Promise ;)


-- Jules


John Gorst wrote:

> Robert Wallace wrote:
>
>> John,
>>
>> The foobar2000 (Windows) player will do very nice conversions from
>> FLAC to MP3 (or almost anything that can run from the command line),
>> but it's only automatic in the sense that it will convert everything
>> it its current playlist using its diskwriter component. The settings
>> on the component let you select the command line encoder (for MP3, I
>> use lame) and its settings. It preserves tags, writing the FLAC tag
>> into and ID3v1 or v2 MP3 tag. It says it will create subdirectories
>> during the MP3 creation process, but I haven't tried to do that, so
>> I'm not sure if it does that the way you want. It's free, which is
>> another nice thing. It's also got a ton of features, and has
>> replaced WinAmp as my desktop player.
>>
>> It's fast enough on my machine that I just drag the tunes I want on
>> my hand-held player into the foobar playlist, select them all,
>> right-click and select Convert. In a few minutes, they're ready to
>> load into my hand-held.
>>
>> Jules is right - command-line rules. But there's nothing wrong with
>> free software if it does what you want.
>>
>> Robert
>
>
> Just about perfect apart from one thing!
> If a file already exists it asks you if you want to overwrite,
> overwrite all or skip. However it does not give you a 'skip all'
> option which is very annoying as it means it converts files even if
> they have been converted previously hence wasting /a lot/ of time!
>
>

Neil Sleightholm
2005-01-17, 11:58
For what it's worth this is my "work in progress" vbscript. It copies
the tag and only creates an MP3 file if one doesn't already exist. The
idea was to support WMA but that bit doesn't work yet. As I said it is
work in progress and might not work! If you improve it feel free to
post the fixes :-).

Const OverwriteExisting = True
Const FLAC = "flac.exe"
Const LAME = "lame.exe"
Const WMADEC = "wmadec.exe"
Const TAG = "tag.exe" ' tag --auto *.mp3

Set fso = CreateObject("Scripting.FileSystemObject")
Set oShell = Wscript.CreateObject("Wscript.Shell")

ShowSubfolders fso.GetFolder("N:")

Sub ShowSubFolders(Folder)

Wscript.Echo Folder.Path

For Each f in Folder.Files

'Wscript.Echo " " & f.Name

ext = lcase(right(f.Name, Len(f.Name) - Instr(f.Name, ".")))
outpath = "O:\MP3s" & Mid(f.ParentFolder, 3) & "\"
basename = left(f.Name, Instr(f.Name, ".") - 1)
Select Case ext
Case "wma"
' THIS DOESN@T WORK YET!
' cmd = WMADEC & " -r 44100 -b 16 -n 2 """ & f.Path & """ | " & LAME
& " --silent -q 2" & _
' " --resample 44100 - """ & outpath & basename & ".mp3"""
' wscript.echo "Converting: " & f.name
' oShell.Run "cmd /c " & cmd, 1, true
'
' cmd = TAG & " --auto --scheme ""A\L\N - T"" """ & outpath &
basename & ".mp3"""
' wscript.echo "Tagging: " & f.name
' oShell.Run "cmd /c " & cmd, 1, true

Case "flac"
cmd = FLAC & " -dcs """ & f.Path & """ | " & LAME & " --silent -q 2"
& _
" --resample 44100 - """ & outpath & basename & ".mp3"""
wscript.echo "Converting: " & f.name
oShell.Run "cmd /c " & cmd, 1, true

cmd = TAG & " --auto --scheme ""A\L\N - T"" """ & outpath & basename
& ".mp3"""
wscript.echo "Tagging: " & f.name
oShell.Run "cmd /c " & cmd, 1, true

Case "mp3"
If Not fso.FileExists(outpath & f.Name) Then
Wscript.Echo "Copying: " & f.name
'Call fso.CopyFile(f.Path, outpath, OverwriteExisting)
End If
End Select

Next

For Each Subfolder in Folder.SubFolders
If Not fso.FolderExists("O:\MP3s" & Mid(Subfolder.Path, 3)) Then
fso.CreateFolder "O:\MP3s" & Mid(Subfolder.Path, 3)
End If
Call ShowSubFolders(Subfolder)
Next

End Sub

John Gorst wrote:

>
> I am trying to search for a solution for the task below - but have
> spent all day with no avail.
>
> I wish to make mp3 copies of all my flac music collection to aid in
> downloading my music onto portable music players.
>
> My music is stored on a linux server running slimserver.
>
> The flac files are stored as one file per track, in directories
> Artist-->Album-->track.flac
>
> I wish to automatically be able to convert my whole flac music
> directory to mp3, storing the mp3s in a different location.
> Maintating the tags is a must, and maintaining the directory tree is
> desireable.
>
> The software can be either windows or linux (as I can access the flac
> files over a samba share). A bonus would be if it detected if it has
> already converted the track previously - but this would be the icing
> on the cake!
>
> Does anyone else so a similar thing in a simple automated fashion?
>
> I know I can setup my cd ripping software to make flac and mp3
> copies, but that does not help convert the 100 flac albums already
> ripped!
>
> Thanks for any help!