Help - Search - Members - Calendar
Full Version: FLAC re-encoding
Hydrogenaudio Forums > Lossless Audio Compression > FLAC
Pages: 1, 2, 3, 4, 5, 6
gottkaiser
Hey,

I want to re-encode my FLAC files with "FLAC Frontend". If I'll give a FLAC file as input, I get a Wave file decoded. Then I would need to encode it again. Because the programm tells me that I can just use Wave file as input to encode to FLAC.
If I do it like that I need lot's of time and I would lose all Tags.

Now I would like to know if there is a command line option to re-encode FLAC files with the "flac.exe", that I could keep my Tags.
Or is ther a good freeware program? (I would prefere the comand line option)


Thanks in advance.
Synthetic Soul
QUOTE(gottkaiser @ Dec 14 2006, 09:49) *
Now I would like to know if there is a command line option to re-encode FLAC files with the "flac.exe", that I could keep my Tags.
Yes. FLAC 1.1.3 will accept FLAC files as input and will transfer tags.

CODE
FLAC.EXE -8 -V -o new.flac old.flac

sshd
flac -f filename.flac
Synthetic Soul
QUOTE(sshd @ Dec 14 2006, 12:10) *
flac -f filename.flac
If you use this method it may be worth reading this thread. I'm never keen on overwriting or deleting files before I'm sure that the conversion is successful.
LotharZ
There is some way to automatize all this process?

Some kind of frontend that supports flac2flac or a batch file?

thx
Martin F.
for /r %i in (*.flac) do start /low /wait flac --best --force "%i"
or
for /r %i in (*.flac) do start /low /wait flac -A "tukey(0,5)" --best --force "%i"
smile.gif
LotharZ
first thx Martin F.

and by the other way, I modified your command to create another file with the new encode, this could be usefull to someone and if its wrong probably someone can fix my command's sintaxis (Im not exactly an expert with flac smile.gif )

CODE
for /r %i in (*.flac) do start /low /wait flac --best --force -V "%i" --output-name="%i_"
Synthetic Soul
I would have thought "%i_" would leave you with "<name>.flac_"?

A better solution may be:

CODE
for /r %i in (*.flac) do start /low /wait flac --best --force -V "%i" --output-name="%~dpni.new.flac"

This should convert "<name>.flac" to "<name>.new.flac".
Jebus
Omni Encoder will also do this, no weird command-line twiddling involved.
agentk7
QUOTE(Synthetic Soul @ Dec 26 2006, 15:06) *

I would have thought "%i_" would leave you with "<name>.flac_"?

A better solution may be:

CODE
for /r %i in (*.flac) do start /low /wait flac --best --force -V "%i" --output-name="%~dpni.new.flac"

This should convert "<name>.flac" to "<name>.new.flac".


Is this the exact command line to use? I must be missing something because when I try it I get this error "ERROR: -o/--output-name cannot be used with multiple files".
LotharZ
@agentk7

It's only a whole line.
krabapple
I can get foobar2k v0.9.4.2 to transcode from flac 1.1.0 to 1.1.3, and transfer all the tags, using flac.exe as a custom commandline encoder, but I can't figure out how to get it to delete the old flac file (or overwrite it). I've tried -delete-input-file, or -f (where output directory = input dir), and nothing I've tried works. (ps, also tried --delete-input-file, and that does nothing)

some of the parameters I've tried:

-8 -delete-input-file - -o %d

-8 -delete-input-file %s -o %d

-8 -f - -o %d

-8 -f %s -o %d
collector
[quote name='krabapple' date='Jan 4 2007, 14:55' post='461910']
(ps, also tried --delete-input-file, and that does nothing)

It certainly is --delete-input-file (--) The helpfiles say it only deletes files when no errors occurred.

I'm not familiar with foobar, but I use the (dos)commandline with a program called glob.exe. Don't know where I got it from, sorry. Search the net for it ?

The syntax from the batchfile I use is "glob.exe -c flac.exe -6 --force --delete-input-file -S- *.flac"
Without the quotes. Maybe its syntax is overcomplete but this works for me. And also works for *.wav

Egor
Regarding deletion of source files in foobar2000: fb2k's converter cannot delete the original file.
krabapple
I notice that flac-to-flac transcodes (using command line flac.exe and, I guess, metaflac.exe) automatically transfer many of the metadata tags from old file to new -- all the standards as well as COMPOSER and COMMENTS -- which is great. However it does not seem to transfer the old replaygain values to the new. Is that even possible? If it requires a -T NAME=VALUE in the command line as per vorbis comments what are the VALUE variables for replaygain track peak, track gain, album peak, album gain? For that matter, I'm not even sure how the NAME should be written -- e.g. with underscores?

-T replaygain_track_gain=" ? "
krabapple
QUOTE(Synthetic Soul @ Dec 14 2006, 05:13) *

QUOTE(gottkaiser @ Dec 14 2006, 09:49) *
Now I would like to know if there is a command line option to re-encode FLAC files with the "flac.exe", that I could keep my Tags.
Yes. FLAC 1.1.3 will accept FLAC files as input and will transfer tags.

CODE
FLAC.EXE -8 -V -o new.flac old.flac




When I run that , it first warns me my input file is not a WAV file and will be treated as a raw file, then throws an error because I have not specified --endian, --sign, etc. So no file is output.

Does this command actually work for you, to reencode from flac to flac? So far none of the command lines or batch scripts posted here work for me, using flac 1.1.0 or 1.1.2 files as input,and hoping for a smaller flac 1.1.3 file as output.
Synthetic Soul
Are you sure that you are testing with FLAC 1.1.3?

It works fine here:

CODE
C:\Documents and Settings\Neil\Desktop>flac112 test.wav

flac 1.1.2, Copyright (C) 2000,2001,2002,2003,2004,2005  Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY.  This is free software, and you are
welcome to redistribute it under certain conditions.  Type `flac' for details.

options: -P 4096 -b 4608 -m -l 8 -q 0 -r 3,3
test.wav: wrote 197077 bytes, ratio=0.464

C:\Documents and Settings\Neil\Desktop>flac -o new.flac test.flac

flac 1.1.3, Copyright (C) 2000,2001,2002,2003,2004,2005,2006  Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY.  This is free software, and you are
welcome to redistribute it under certain conditions.  Type `flac' for details.

test.flac: wrote 195137 bytes, ratio=0.990

Edit: If I use 1.1.2 to try to re-encode I get:

CODE
C:\Documents and Settings\Neil\Desktop>flac112 -o new2.flac test.flac

flac 1.1.2, Copyright (C) 2000,2001,2002,2003,2004,2005  Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY.  This is free software, and you are
welcome to redistribute it under certain conditions.  Type `flac' for details.

options: -P 4096 -b 4608 -m -l 8 -q 0 -r 3,3
ERROR: for encoding a raw file you must specify a value for --endian, --sign, --
channels, --bps, and --sample-rate
Type "flac" for a usage summary or "flac --help" for all options

collector
QUOTE(krabapple @ Jan 5 2007, 18:13) *

However it does not seem to transfer the old replaygain values to the new. Is that even possible?

Tested the transcode from v1.1.0 to v1.1.3 and all values were copied. Replaygain values also.

You are sure you overwrote all older versions with the new 1.1.3 ones ?
krabapple
QUOTE(Synthetic Soul @ Jan 6 2007, 02:10) *

Are you sure that you are testing with FLAC 1.1.3?


Yes. I've uninstalled, downloaded and run flac113b installer twice now. flac -v from the command line shows

flac 1.1.3


but I think I've found my error. I've been putting -V 8 in the command line instead of -V -8 -- in other words a stupid typo on my part, probably me half-instinctively reverting to LAME command line syntax for EAC. Flac-to-flac using flac.exe in a terminal window is working now,old file is ovewritten, and replaygain values are transferred. I'm going to go slap myself with a wet fish when I'm done.

The flac batch commands I've copied from threads here still aren't working for me though.
krabapple
This seems to work; I adapted it from one of Synthetic Soul's batch scripts on another thread; obviously it's very much like yours Martin -- except that with only one flac encoder in my system it seems smart enough not to need an explicit encoder statement

CODE

@ECHO OFF
FOR /R %1 %%G IN (*.flac) DO FLAC.EXE --best -V --force "%%G"



all is bliss!

and for even more compressed bliss, this substitutes a much slower but more aggressive encode I got from a post by JWolf

CODE

@ECHO OFF
FOR /R %1 %%G IN (*.flac) DO FLAC.EXE -8 -A tukey(0.25) -A gauss(0.1875) -b 4096 -V --force "%%G"




Bjork Homogenic directory -- size/size on disc, as reported by Windows

flac 1.1.0 probably set at -8
294 MB (308,537,323 bytes)/294 MB (308,559,872 bytes)

flac 1.1.3 --best
293 MB (307,439,199 bytes)/293 MB (307,462,144 bytes)

flac1.1.3 -8 -A tukey(0.25) -A gauss(0.1875) -b 4096
292 MB (307,129,792 bytes)/292 MB (307,150,848 bytes)
Martin H
Nice to hear that you have gotten it sorted out now smile.gif

I added the %encoder% variable to the script in case you haden't flac.exe located somewhere within your PATH environment variable and so as to avoid you having to move it there for getting the script to work. Also your change to use %%G instead of %%F was also a good change, since i have just read that even though all letters can be used, then %%G are recommended to be used as e.g. using %%F and also some other letters could actually make some problems and also break a FOR script on NT4 systems.

Anyway, Nice work on making a functioning script and i'm happy that you've gotten it sorted out eventually smile.gif

CU, Martin.
Synthetic Soul
I have created a batch file to convert to FLAC 1.1.3.

If you drag a file or folder onto the batch file it will process all FLAC files within (including subfolders).

It will first use -t to test the source file, and only if the test is successful will then re-encode the file using -fto force an overwrite . Edit: Version 1.1.0 now encodes to a new file, and if the encode was successful will then overwrite the source with the new file (MOVE /Y <new file> <old file>). This should now ensure that the souce is only ever overwritten if the process has been 100% successful.*

If any files do fail testing or re-encoding they will be listed once all processing has finished.

To use the batch file you need to first open it in Notepad and amend the lines:

CODE
SET pathToFLAC="FLAC.EXE"
SET flacOptions=-8

... to suit. You really only need quotes around pathToFLAC if the path contains spaces. The switches -V -f are hardcoded into the command line already.

Hopefully some people will find this useful.

* DISCLAIMER: But, of course, it may. Don't blame me. Test before you run it on anything precious.
edwardar
Thanks for the batch file - just what I was looking for. Unfortunately it's not working properly (using 1.0.0 or 1.1.0).

My directory structure is:

I:\albums\artist1 - year1 - album1\artist1 - year1 - album1.flac
I:\albums\artist2 - year2 - album2\artist2 - year2 - album2.flac
etc...

and when I drag the albums folder onto the batch file it keeps rencoding "artist1 - year1 - album1.flac" and doesn't move on to the next one. Could you have a look at that?

Cheers,

Ed
Synthetic Soul
Here's my test (1.1.0 used):

CODE
Checking: "L:\albums"

Testing: "L:\albums\artist1 - year1 - album1\artist1 - year1 - album1.flac"
________________________________________________________________________

flac 1.1.3, Copyright © 2000,2001,2002,2003,2004,2005,2006 Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
welcome to redistribute it under certain conditions. Type `flac' for details.

artist1 - year1 - album1.flac: ok

Encoding: "L:\albums\artist1 - year1 - album1\artist1 - year1 - album1.flac"
________________________________________________________________________

flac 1.1.3, Copyright © 2000,2001,2002,2003,2004,2005,2006 Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
welcome to redistribute it under certain conditions. Type `flac' for details.

artist1 - year1 - album1.flac: Verify OK, wrote 256863 bytes, ratio=1.000


Testing: "L:\albums\artist2 - year2 - album2\artist2 - year2 - album2.flac"
________________________________________________________________________

flac 1.1.3, Copyright © 2000,2001,2002,2003,2004,2005,2006 Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
welcome to redistribute it under certain conditions. Type `flac' for details.

artist2 - year2 - album2.flac: ok

Encoding: "L:\albums\artist2 - year2 - album2\artist2 - year2 - album2.flac"
________________________________________________________________________

flac 1.1.3, Copyright © 2000,2001,2002,2003,2004,2005,2006 Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
welcome to redistribute it under certain conditions. Type `flac' for details.

artist2 - year2 - album2.flac: Verify OK, wrote 256863 bytes, ratio=1.000


2 file(s) processed.
2 file(s) encoded.
0 file(s) returned an error.

Press any key to exit

Bear in mind that FLAC first tests the file, and then re-encodes the file. Are you sure you are not seeing the test and then the re-encode?
edwardar
Yeah, I'm pretty sure, here's my output:

CODE
Checking: "I:\Albums"

Testing: "I:\Albums\Guns N' Roses - 1987 - Appetite For Destruction\Guns N' Rose
s - 1987 - Appetite For Destruction.flac"
________________________________________________________________________

flac 1.1.3, Copyright (C) 2000,2001,2002,2003,2004,2005,2006  Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY.  This is free software, and you are
welcome to redistribute it under certain conditions.  Type `flac' for details.

Guns N' Roses - 1987 - Appetite For Destruction.flac: ok

Encoding: "I:\Albums\Guns N' Roses - 1987 - Appetite For Destruction\Guns N' Ros
es - 1987 - Appetite For Destruction.flac"
________________________________________________________________________

flac 1.1.3, Copyright (C) 2000,2001,2002,2003,2004,2005,2006  Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY.  This is free software, and you are
welcome to redistribute it under certain conditions.  Type `flac' for details.

Guns N' Roses - 1987 - Appetite For Destruction.flac: 100% complete, ratio=0.993
Guns N' Roses - 1987 - Appetite For Destruction.flac: 100% complete, ratio=0.993
Guns N' Roses - 1987 - Appetite For Destruction.flac: 100% complete, ratio=0.993
Guns N' Roses - 1987 - Appetite For Destruction.flac: 100% complete, ratio=0.993
Guns N' Roses - 1987 - Appetite For Destruction.flac: 100% complete, ratio=0.993
Guns N' Roses - 1987 - Appetite For Destruction.flac: 100% complete, ratio=0.993
Guns N' Roses - 1987 - Appetite For Destruction.flac: 100% complete, ratio=0.993
Guns N' Roses - 1987 - Appetite For Destruction.flac: 100% complete, ratio=0.993
Guns N' Roses - 1987 - Appetite For Destruction.flac: 100% complete, ratio=0.993
Guns N' Roses - 1987 - Appetite For Destruction.flac: 100% complete, ratio=0.992
Guns N' Roses - 1987 - Appetite For Destruction.flac: Verify OK, wrote 403736967
bytes, ratio=0.992


Testing: "I:\Albums\Guns N' Roses - 1987 - Appetite For Destruction\Guns N' Rose
s - 1987 - Appetite For Destruction.flac"
________________________________________________________________________

flac 1.1.3, Copyright (C) 2000,2001,2002,2003,2004,2005,2006  Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY.  This is free software, and you are
welcome to redistribute it under certain conditions.  Type `flac' for details.

Guns N' Roses - 1987 - Appetite For Destruction.flac: ok

Encoding: "I:\Albums\Guns N' Roses - 1987 - Appetite For Destruction\Guns N' Ros
es - 1987 - Appetite For Destruction.flac"
________________________________________________________________________

flac 1.1.3, Copyright (C) 2000,2001,2002,2003,2004,2005,2006  Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY.  This is free software, and you are
welcome to redistribute it under certain conditions.  Type `flac' for details.

Guns N' Roses - 1987 - Appetite For Destruction.flac: 1% complete, ratio=0.907

Ed
Synthetic Soul
Sorry, I have no idea. If I use that setup with my previous test I get:

CODE
Processing: "L:\albums"

Testing: "L:\albums\Guns N' Roses - 1987 - Appetite For Destruction\Guns N' Rose
s - 1987 - Appetite For Destruction.flac"
________________________________________________________________________

flac 1.1.3, Copyright © 2000,2001,2002,2003,2004,2005,2006 Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
welcome to redistribute it under certain conditions. Type `flac' for details.

Guns N' Roses - 1987 - Appetite For Destruction.flac: ok

Encoding: "L:\albums\Guns N' Roses - 1987 - Appetite For Destruction\Guns N' Ros
es - 1987 - Appetite For Destruction.flac"
________________________________________________________________________

flac 1.1.3, Copyright © 2000,2001,2002,2003,2004,2005,2006 Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
welcome to redistribute it under certain conditions. Type `flac' for details.

Guns N' Roses - 1987 - Appetite For Destruction.flac: Verify OK, wrote 256863 by
tes, ratio=1.000


Testing: "L:\albums\Hartist2 - year2 - album2\artist2 - year2 - album2.flac"
________________________________________________________________________

flac 1.1.3, Copyright © 2000,2001,2002,2003,2004,2005,2006 Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
welcome to redistribute it under certain conditions. Type `flac' for details.

artist2 - year2 - album2.flac: ok

Encoding: "L:\albums\Hartist2 - year2 - album2\artist2 - year2 - album2.flac"
________________________________________________________________________

flac 1.1.3, Copyright © 2000,2001,2002,2003,2004,2005,2006 Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
welcome to redistribute it under certain conditions. Type `flac' for details.

artist2 - year2 - album2.flac: Verify OK, wrote 256863 bytes, ratio=1.000


________________________________________________________________________

2 file(s) processed.
2 file(s) encoded.
0 file(s) returned an error.

Press any key to exit

I cannot think at all why that would be happening to you. Can you try with a test folder with a different filename to see if that makes any difference? Use a smaller file to make the test a little easier; I have just used the Windows Startup sounds as a small test wave.

Also, perhaps you could save the following to a file called "test.bat". Drag your "Albums" folder onto the batch file and then paste the contents of "test.txt" (created by test.bat) here.

CODE
@ECHO OFF
FOR /R %1 %%G IN (*.flac) DO CALL :ListFiles "%%G"
GOTO:EOF
:ListFiles
ECHO %1>>"%~dp0test.txt"
GOTO:EOF

Edit: Sorry, just tested on XP and I get the same as you! I can only think that, as the files are changing, they are being entered back into the collection of FLAC files to be processed. This does not happen on Win2K. I'll have to have a think. NB: test.bat works as expected, which is why I think it is to do with the files changing. It would be a lot easier to do if the script encoded to new files (new path).

Thanks for the info. Sorry to have wasted your time. sad.gif I will upload a script that works on XP...
Synthetic Soul
OK, the batch file has been updated. smile.gif

To resolve the XP issue it now first creates a list of the files to process in a temporary file. It then processes each line of that file as per previously (testing, encoding to new file and then overwriting source).

I hope this helps. Sorry for the previous problems.
philaphonic
This batch file doesn't recursively process directories, does it?

I *need* to learn to do batch files myself one day.

Thank you for the work.
Synthetic Soul
Yes, it does work recursively.
krabapple
QUOTE(Martin H @ Jan 6 2007, 19:46) *

Nice to hear that you have gotten it sorted out now smile.gif

I added the %encoder% variable to the script in case you haden't flac.exe located somewhere within your PATH environment variable and so as to avoid you having to move it there for getting the script to work. Also your change to use %%G instead of %%F was also a good change, since i have just read that even though all letters can be used, then %%G are recommended to be used as e.g. using %%F and also some other letters could actually make some problems and also break a FOR script on NT4 systems.

Anyway, Nice work on making a functioning script and i'm happy that you've gotten it sorted out eventually smile.gif

CU, Martin.


And thank you for your input.

I certainly can't take credit for anyting in the script -- it was almost entirely a cut an past of this
script by Synthetic Soul. My only 'addition' was to elaborate the flac parameters -- and even those were copied! biggrin.gif

Syntehtic Soul,
Thanks go to you too.
I haven't tried your new batch file yet -- my 'older' one has now been running for two days and probably has that many more to go, so I could halt it and launch the rest of the files into the new batch. I had thought that the -V option would prevent overwriting of original files by any 'failed' re-encodes, but is that perhaps not true? Does --force trump -V?
LotharZ
Found this problem, Its a re-encoder error but Im posting it here due to the batch file dont manage it correctly.

Its saying that the file is encoded correctly when obviously there is an error.

CODE
Testing: "E:\MP3\Depeche Mode\Playing The Angel\Depeche Mode - Damaged People.fl
ac"
________________________________________________________________________

flac 1.1.3, Copyright © 2000,2001,2002,2003,2004,2005,2006  Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY.  This is free software, and you are
welcome to redistribute it under certain conditions.  Type `flac' for details.

Depeche Mode - Damaged People.flac: ok

Encoding: "E:\MP3\Depeche Mode\Playing The Angel\Depeche Mode - Damaged People.f
lac"
________________________________________________________________________

flac 1.1.3, Copyright © 2000,2001,2002,2003,2004,2005,2006  Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY.  This is free software, and you are
welcome to redistribute it under certain conditions.  Type `flac' for details.

WARNING: E:\MP3\Depeche Mode\Playing The Angel\Depeche Mode - Damaged People.fla
c is not a WAVE file; treating as a raw file
ERROR: for encoding a raw file you must specify a value for --endian, --sign, --
channels, --bps, and --sample-rate
Type "flac" for a usage summary or "flac --help" for all options
The system cannot find the file specified.


1 file(s) processed.
1 file(s) encoded.
0 file(s) returned an error.

Press any key to exit
Synthetic Soul
I'm afraid FLAC must still be returning the exit code of zero, even though there was a problem.

Not sure why it would do that! Not something I can fix I'm afraid.

It looks like you are seeing the same problem that krabapple reported in post #16. I wonder why FLAC doesn't like those FLAC files? Any idea why that file may be different, so I can simulate and test?

Edit: I've just tested by putting a PAUSE in between the test and encode, and manually corrupting the file before letting encoding continue. This results in:

CODE
test.flac: ERROR got FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC while decoding FLAC input
test.flac: ERROR got FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC while decoding FLAC input
test.flac: 8% complete, ratio=1.169

... and still an exit code of zero, which normally signifies a successful operation (I thought).

If FLAC will not return a non-zero code on errors I'm afraid there's nothing I can do. Please note that the previous test should catch most errors though. That does return a non-zero code on error (tested).
krabapple
QUOTE(Synthetic Soul @ Jan 8 2007, 12:19) *

I'm afraid FLAC must still be returning the exit code of zero, even though there was a problem.

Not sure why it would do that! Not something I can fix I'm afraid.

It looks like you are seeing the same problem that krabapple reported in post #16. I wonder why FLAC doesn't like those FLAC files? Any idea why that file may be different, so I can simulate and test?


It appears from cursory glance that the main difference between your more intricate batch file and your two-line one is the level of error checking (and logging) . Since the simple one definitely works in XP (two days and running, knock wood!), the issue for me again comes down to , is -V (--verify) insufficient to prevent a bad encode from overwriting a good one (with --force also in effect)? I notice from watching the directory as files are being reencoded, that with the simple script, a tmp file is created , then deleted, for every file as it's reencoded. So I would hope that if -V finds a problem, the old file is not overwritten.

Also, I notice a peculiar thing, that even though the reencoded files have definitely been modified (shrunk) by the simple script, the modification date does not change! I'd rather it did, if only to check for failed re-encodes.





Synthetic Soul
I don't believe that I have written a 2 line solution, which may explain why it works. wink.gif I'm glad the solution's working for you though.

Yes, I noticed about the dates not changing also. I assume this is a feature. I had a quick look to see if there was a switch to change this behaviour, but couldn't see one.
krabapple
QUOTE(Synthetic Soul @ Jan 8 2007, 13:59) *

I don't believe that I have written a 2 line solution, which may explain why it works. wink.gif


Thanks, but the 'solution' I posted is copied almost directly from one of yours...I linked to your original a few posts back. It's post #6 in this thread, from April 2005. It's actually one line!

http://www.hydrogenaudio.org/forums/index....;p=290743&#

Don't be modest, take a bow! biggrin.gif
Teknojnky
Just want to say THANKS! for the batch script, it seems to be working great for me.

I added --replay-gain as one of the SET flacOptions parameters to (re)calculate gain in case any files were missing it.


edit:

is there a way to run the encoding as 'idle' or 'lowest' priority, so I can run it in the background without making foreground apps run slower?
krabapple
With some trepidation, I have made two versions of the 'simple' .bat file available for FTP, one using --best and the other using the more extreme compression setting. If interested, download this README first, as it contains the links to the two .bat files.

http://www.m-ideas.com/public_html/sullivan/flac/README.txt
Marino13
QUOTE(Synthetic Soul @ Jan 7 2007, 13:57) *

Yes, it does work recursively.


SS,

How would I add a command line to embed a jpeg of the album cover into the new flac file? My folder structure is F:\Artist\Album\tracknumber - title.flac. I have a folder.jpg of each covert art inside the Albums folder. So it is basically F:\Artist\Album\folder.jpg. Any way to do this? I have about 27,000 flac files and would not be able to do hese individually.
jcoalson
@LotharZ, can you host the FLAC file that's causing the problem? or at least the first 100k of it? also, if you test it with 'flac -tF' does it say?

QUOTE(krabapple @ Jan 8 2007, 13:37) *
...the issue for me again comes down to , is -V (--verify) insufficient to prevent a bad encode from overwriting a good one (with --force also in effect)? I notice from watching the directory as files are being reencoded, that with the simple script, a tmp file is created , then deleted, for every file as it's reencoded. So I would hope that if -V finds a problem, the old file is not overwritten.

yep, that's how it's supposed to work. an alternative (if you have the disk space) is to use --output-prefix to send recodes to another dir, then test afterward and replace. then you won't need --force either.

QUOTE(krabapple @ Jan 8 2007, 13:37) *
Also, I notice a peculiar thing, that even though the reencoded files have definitely been modified (shrunk) by the simple script, the modification date does not change! I'd rather it did, if only to check for failed re-encodes.

yes, by default flac keeps the modtime and permissions (like gzip, compress, etc). metaflac has --preserve-modtime which flac maybe should also have, but if you want the modtime you can "touch" the file after recoding.

Josh
Synthetic Soul
QUOTE(Marino13 @ Jan 8 2007, 21:50) *
How would I add a command line to embed a jpeg of the album cover into the new flac file? My folder structure is F:\Artist\Album\tracknumber - title.flac. I have a folder.jpg of each covert art inside the Albums folder. So it is basically F:\Artist\Album\folder.jpg. Any way to do this? I have about 27,000 flac files and would not be able to do hese individually.
I'm not really up on the --picture switch syntax, and I don't really want to get into this too much, but you would reference the file using:

"%~dp1folder.jpg"

So, you would change the encoding command line to something like (not sure if syntax is correct):

CODE
%pathToFLAC% %flacOptions% --picture="|image/jpeg|||%~dp1folder.jpg" -V -o "%~dpn1-flac-113.flac" %1

Edit: Hmmm... looks like it may be worth looking at this thread. It seems you can't use --picture when the source is a FLAC. blink.gif

QUOTE(Teknojnky @ Jan 8 2007, 20:39) *
Just want to say THANKS! for the batch script, it seems to be working great for me.
...
is there a way to run the encoding as 'idle' or 'lowest' priority, so I can run it in the background without making foreground apps run slower?
Glad it's helping. I would do this by calling the batch file from the command line, e.g.:

CODE
START /LOW /B FLAC-113 "path\to\folder"

I believe that this would make all calls to FLAC in low priority (as a child process). I'm not sure though, I don't really use this. I tend to start a script and leave the PC well alone.
Synthetic Soul
@Josh,

Are you able to shed any light on FLAC.EXE still returning 0 when an error occurs? Am I wrong in my understanding?

If this is the case, would you consider amending the behavior so that batch files, or other scripts, could act accordingly?
jcoalson
yes, it's not supposed to return 0 in this case, I'm hoping with the file I can debug what's wrong.
LotharZ
QUOTE(jcoalson @ Jan 8 2007, 22:52) *

@LotharZ, can you host the FLAC file that's causing the problem? or at least the first 100k of it? also, if you test it with 'flac -tF' does it say?


This is the result of 'flac -tF' command.

CODE
C:\Program Files\BeLight>flac -tF "Depeche Mode - Damaged People.flac"

flac 1.1.3, Copyright (C) 2000,2001,2002,2003,2004,2005,2006  Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY.  This is free software, and you are
welcome to redistribute it under certain conditions.  Type `flac' for details.

Depeche Mode - Damaged People.flac: ok


but every command trying to reencode the file gives "WAV Error". (I can decode without problems).

Already uploaded one of the files here: Moderation: link removed

If you have some problem downloading, let me know a place that works for you and i'll reupload tomorrow.

G'nite.
jcoalson
got the file... the problem is the id3v2 tag on the front of it.

Josh
LotharZ
Perfect, removing all tags from files let me reencode them without problems. (I'm not sure how the hell ended an id3v2 tag there, hehe)

thx
Synthetic Soul
I have updated my batch file to use an alternative syntax for getting the exit code, and it appears to work... properly!

I have tested with my corrupted files and LotharZ's dodgy file, and both types are picked up - mine on testing ([T]) and his on encoding ([E]).

CODE
9 file(s) processed.
6 file(s) encoded.
3 file(s) returned an error.

Files that failed:

  "C:\Documents and Settings\Neil\Desktop\Media\bad.flac" [T]
  "C:\Documents and Settings\Neil\Desktop\Media\bad2.flac" [T]
  "C:\Documents and Settings\Neil\Desktop\Media\Depeche Mode - Damaged People.flac" [E]

I appear to be behind a proxy so downloading got me version 2.0.0. Ensure that you have version 2.1.0 (version number can be found near the top and in the version history at the bottom).

NB: I have kept both stages in, and in the original order. I tried removing the initial test (-t), but the corrupted files (bad.flac and bad2.flac) got through the encoding verification. I also cannot encode then test, as once encoded, even if the recode was not 100% accurate (e.g.: bad.flac is converted from 195KB to 9KB) the result is a valid file (it seems) so the file passes the test. Testing then verifying the encode seems to be the best method.

Hopefully I'm done with this now. I wish I'd never bothered to be honest!
Teknojnky
QUOTE(Synthetic Soul @ Jan 9 2007, 05:04) *

Hopefully I'm done with this now. I wish I'd never bothered to be honest!



biggrin.gif

I was thinking of something, duno if your interested (doesn't look like now hah), or feasible..

- option to skip files that are already 1.1.3 encodes.

This would make it super easy to drag an entire library on it and only re-encode new files that aren't 1.1.3 versions.

Thanks again for the script!
Synthetic Soul
I guess that could be achieved using this tool.

I didn't actually realise that this tool comes with some bacth files that pretty much do what mine does. rolleyes.gif

Ah well, in for a penny...
Synthetic Soul
OK, version 2.2.0. smile.gif

If FlacGetV.exe (and libFLAC.dll and libmmd.dll) is in the same directory as the batch file it will be used to check the vendor string, and skip 1.1.3 files.

If FlacGetV.exe is not present it will act as per 2.1.0.

CODE
9 file(s) processed.
8 file(s) skipped (already 1.1.3).
0 file(s) encoded.
1 file(s) returned an error.

Files that failed:

  "C:\Documents and Settings\Neil\Desktop\Media\Depeche Mode - Damaged People.flac" [E]

Teknojnky
Haha great work, thanks again! cool.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.