Help - Search - Members - Calendar
Full Version: FLAC re-encoding
Hydrogenaudio Forums > Lossless Audio Compression > FLAC
Pages: 1, 2, 3, 4, 5, 6
dagordon
For us Vista users out there, there's a problem if you try to drop a folder onto flac-113.bat. The problem also happens with flac-verify, another one of Synthetic Soul's invaluable scripts.

There's an easy solution. With both flac-113.bat and flac-verify.bat, find the line

CODE
IF %~z1 EQU 0 (CALL :FolderAction %1) ELSE (CALL :FileAction %1)


Replace 'IF %~z1 EQU 0' with 'IF %~x1x==x', yielding

CODE
IF %~x1x==x (CALL :FolderAction %1) ELSE (CALL :FileAction %1)


Explanation:

In previous versions of Windows %~z1 would yield the file size of the object passed to the batch file; if it's a folder it would be 0. But in Vista for whatever reason %~z1 is not 0 if a folder is passed (incidentally, it doesn't even seem to be the folder's size).

So the fix looks at the extension of what's passed to the batch file; if it's a file then it has an extension, if it's a folder it has none.
paulgj
Hello,

I love the script but I am having a recurring problem when running it, which may or may not be related to the script itself.

When I set the script to run a very large number of converts (i.e. I drop a folder on it with many hundreds if not thousands of files) I find that eventually the converting will pause or "stall" at a certain percentage of a file and the CPU usage will drop to zero (according to the task manager), it will then resume after maybe a minute or so and then stop again later in the file.

If I cancel the script and re-run the behavior will return almost immediately, but If I reboot I can rerun a lot of files again before the problem repeats itself.

I'm wondering if there's some kind of memory leak?

Anyone else have this problem? Running WinXP SP2 with 768MB RAM

Thanks for any ideas.
-Paul
ludwig
Hi, I don't know why, but since 1.2.0 then 1.2.1, there're more and more failed. And something strange: if I download for instance a concert from a p2p website, then use the script,
1) I have the track 05 failed;
2) I download again only the 05; then use script again (on all the concert files)
3) 05 is ok, but 06 failed, whereas it was 1.2.1 and ok just before !!!!

What's wrong ?

Regards
Synthetic Soul
Personally I have no idea; it doesn't appear to make logical sense.

Perhaps you could post some of the errors/reports you have been receiving.
wdekler
I just used flac-113 (with dagordon's Vista fix) to convert a bunch of flac files. I noticed that some files failed to convert but I'm not sure why (for example) these files fail:

"c:\audio\Collectie\Robert Cray Band\False Accusations\07 - The Last Time (I Get Burned Like This).flac" [E]
"c:\audio\Collectie\Robert Cray Band\Twenty\02 - That Ain't Love.flac" [T]

I've already manually converted them to flac 1.21 without any problems...


thanks!
Synthetic Soul
It's possible that the brackets and apostrophe are causing problems. I know there was an issue with percent signs; it's possible that these characters are throwing it out also.

I'm not supporting the script anymore, and I cannot test on Vista. Sorry.

I would use foobar.
wdekler
OK,thanks. I guess that the brackets and the ' character are the culprits here... dry.gif
Mr Bungle
Hi,

Can anyone advise me of the official tag for stating the encoder version?

It seems foobar is looking for the "tool" field. This worked fine when I was ripping with EAC+MAREO+FLAC&OGG - I ended up with the tool field being populated for both the ogg and FLAC files and foobar was happy.

Now I am trying flac-113.bat with FlacGetV and finding the tool tag is remaining untouched. I know the re-encoding is working as FlacGetV reports the file as being the new version, and the file is smaller due to better compression (1.21 vs 1.1.2). However, foobar is not looking at whatever tag is being used, and instead looks at the tool tag with the old version.

EDIT: Is it VORBIS_COMMENT?

Also, is there a way of incorporating metaflac with parameter --add-replay-gain into the batch file? Or should I just use have --add-replay-gain in the 'SET flacOptions' section? Note some of my files already have replay-gain tags, obtained using metaflac.exe and glob.exe.

Regards,
Jeff
I am all FLAC
For Linux users put this script in your path.
CODE

#!/bin/sh

OUTPUT="recoded"
mkdir $OUTPUT

for f in *flac; do
flac "$f" --best -V -o $OUTPUT/"$f"
done


It makes a directory "recoded" in the current directory (where the flac files you want to re-encode are) and re-encodes to that new directory.

Afterwards can you just type
CODE
rm *flac
mv recoded/* .
rm -r recoded

And your album is re-encoded biggrin.gif



jcoalson
even simpler:
CODE
mkdir recoded
flac --output-prefix=recoded/ --best -V *.flac && mv recoded/*.flac . && rmdir recoded
ludwig
@ jcoalson
you wrote: "mkdir recoded
flac --output-prefix=recoded/ --best -V *.flac && mv recoded/*.flac . && rmdir recoded"
Could you give the whole script / way to do the same under linux, please ?
I'm beginner
Regards
jcoalson
that is how you do it in linux, it will work in evey shell that I know of (sh, bash, csh, etc)
ludwig
QUOTE(jcoalson @ Jan 16 2008, 08:08) *

that is how you do it in linux, it will work in evey shell that I know of (sh, bash, csh, etc)

Thank you, again, again and again, for all your work and generosity !
jcoalson
my pleasure, always glad to hear when it's useful.

bash is also really useful for all kinds of things. if you're new, this book is good: http://www.oreilly.com/catalog/bash3/?CMP=AK
Jose Hidalgo
Hi everybody, and big thanks to Synthetic Soul for this useful script ! biggrin.gif

This script would be perfect for me... if only I could specify a "source" and a "destination" directory ! I've just got a new HD, and I need to copy all my 20.000+ FLAC files to it. But I'd like to take this opportunity to verify them / make sure they're good before re-encoding them and copying them to the new HD (no need to delete source files BTW). So that I'm sure that all the copied files are perfect (they will be within a RAID 5 array, so they will be quite safe there... once I can copy them of course).

So I need to use some efficient and secure tool (this script ? foobar ? something else ?) that can :
- take a source AND a destination directory,
- scan the source directory (and all its subfolders, sub-subfolders, etc.)
- check the FLAC files for corruption / non-proper id3v2 tags, etc.,
- if one given FLAC file is good, re-encode it and copy it to the new destination directory (preserving folder hierarchy of course, i.e. creating all necessary folders within the destination directory),
- if not, log the faulty FLAC file (i.e. give me some text report of all failed files so I can check them one by one manually).

Again, Synthetic Soul's script would be perfect for me... if only it had this feature implemented.

Can somebody please help me ? Many thanks in advance. smile.gif
Synthetic Soul
The code below is a hacked version of the script. This script adds the following variables:

CODE
SET srcRoot=C:\Source Folder
SET dstRoot=D:\Destination Folder

So, if your files are in the structure "C:\My Music\<artist>\<album>" you should set srcRoot to C:\My Music.

Ensure that the paths are accurate, and in the same format - i.e.: if you leave a slash at the of srcRoot ensure that dstRoot also ends in a slash. The script will simply take the path of the source file and replace the text set in srcPath with that in destPath, so "C:\Source Folder\Pixies\Doolittle\01 - debaser.flac" will convert to "D:\Destination Folder\Pixies\Doolittle\01 - debaser.flac".

I have tested, briefly, but you would do well to test thoroughly yourself, before running on your library.


CODE
@ECHO OFF
CLS

REM FLAC-113-HACK.BAT Written by Neil Popham, 2008 (neilpopham@bigfoot.com)

SET batchname=FLAC-113-HACK.BAT
SET version=0.0.1
TITLE=%batchname%, Version %version%

REM ######################################################
SET pathToFLAC="FLAC.EXE"
SET flacOptions=-8
SET retainListOfFailedFiles=1
SET retainListOfProcessedFiles=0
SET retainListOfSuccessfulFiles=0
SET flacVersion=121
SET srcRoot=C:\Source Folder
SET dstRoot=D:\Destination Folder
REM ######################################################

REM Check whether a valid file or folder has been passed
IF NOT EXIST %1 DO GOTO NoParams

REM Set counters
SET /A noProcessed=0
SET /A noErrors=0
SET /A noEncoded=0
SET /A noSkipped=0
SET /A srcBytes=0
SET /A dstBytes=0

REM Set path to the list of failed files depending on whether it is to be kept or not
IF [%retainListOfFailedFiles%] EQU [1] (
SET pathForFails=%~dp0%
) ELSE (
SET pathForFails=%TEMP%\
)

REM Set path to the list of successful files depending on whether it is to be kept or not
IF [%retainListOfSuccessfulFiles%] EQU [1] (
SET pathForSuccess=%~dp0%
) ELSE (
SET pathForSuccess=%TEMP%\
)

REM Set path to the list of files to process depending on whether it is to be kept or not
IF [%retainListOfProcessedFiles%] EQU [1] (
SET pathForList=%~dp0%
) ELSE (
SET pathForList=%TEMP%\
)

REM Clear file used to store failed filenames
IF EXIST "%pathForFails%flac-113-failed.txt" DEL "%pathForFails%flac-113-failed.txt"

REM Clear file used to store successful filenames
IF EXIST "%pathForSuccess%flac-113-successful.txt" DEL "%pathForSuccess%flac-113-successful.txt"

REM Clear file used to store the list of files to process
IF EXIST "%pathForList%flac-113-processed.txt" DEL "%pathForList%flac-113-processed.txt"

REM Check whether the parameter is a single file or a folder
IF %~z1 EQU 0 (CALL :FolderAction %1) ELSE (CALL :FileAction %1)

REM Calculated bytes saved
SET /A dffSize=%srcSize%-%dstSize%

REM Report results
ECHO ________________________________________________________________________
ECHO.
ECHO %noProcessed% file(s) processed
IF EXIST "%~dp0FLACGETV.EXE" ECHO %noSkipped% file(s) skipped (already latest version)
ECHO %noEncoded% file(s) encoded
ECHO %noErrors% file(s) returned an error
IF %noErrors% GTR 0 CALL :ReportFiles
ECHO.
ECHO Settings used: FLAC v.%flacVersion% '%flacOptions%'
ECHO Bytes Saved: %dffSize% bytes

REM Pause
ECHO.
ECHO Press any key to exit
PAUSE >NUL

REM End
GOTO:EOF

REM ==========================================
REM FileAction : single file has been passed
REM ==========================================
:FileAction
REM Do we have a FLAC file?
IF /I [%~x1] EQU [.flac] (
CALL :Encode %1
) ELSE (
REM Do we have a TXT file?
IF /I [%~x1] EQU [.txt] (
REM Process the list of files in the file
SET pathForList="%~dp1"
CALL :ProcessList "%~nx1"
) ELSE (
GOTO NoParams
)
)
GOTO:EOF

REM =======================================
REM FolderAction : folder has been passed
REM =======================================
:FolderAction
REM Check folder and subfolders for FLAC files,call ListFiles for each file, and then Encode
ECHO Processing: "%~1"
ECHO.
REM Create temporary list of files to process
ECHO Creating list of files to process
ECHO.
FOR /R %1 %%G IN (*.flac) DO CALL :ListFiles "%%G"
CALL :ProcessList flac-113-processed.txt
GOTO:EOF

REM =============================================
REM ListFiles : Create list of files to process
REM : %1 The FLAC file to add
REM =============================================
:ListFiles
ECHO %1>>"%pathForList%flac-113-processed.txt"
GOTO:EOF

REM ============================================
REM ProcessList : Encode all files in the list
REM : %1 The text list of files
REM ============================================
:ProcessList
REM Encode each file
PUSHD %pathForList%
FOR /F "tokens=* delims=" %%H IN (%~s1) DO CALL :Encode %%H
POPD
IF [%retainListOfFailedFiles%] EQU [1] (
REM ECHO.>>"%pathForList%flac-113-processed.txt"
REM ECHO List created at %DATE% %TIME%>>"%pathForList%flac-113-processed.txt"
) ELSE (
DEL "%pathForList%flac-113-processed.txt"
)
GOTO:EOF


REM =====================================
REM Encode : Encode FLAC file
REM : %1 The FLAC file to Encode
REM =====================================
:Encode
REM Check the vendor string to see if the file is already the latest version
IF EXIST "%~dp0FLACGETV.EXE" (
ECHO Checking Vendor: "%~1"
ECHO ________________________________________________________________________
"%~dp0FLACGETV.EXE" %1
ECHO.
)
REM Create destination path from source path
SET dst=%~1
SET dst=%dst::=?%
SET srcRoot=%srcRoot::=?%
SET dstRoot=%dstRoot::=?%
CALL SET dst=%%dst:%srcRoot%=%dstRoot%%%
SET dst=%dst:?=:%
FOR %%I IN ("%dst%") DO SET dstf="%%~dpI"
IF %ERRORLEVEL% EQU %flacVersion% (
SET /A noSkipped+=1
ECHO File is already the latest version [%flacVersion%]
) ELSE (
REM Test the original
ECHO Testing: "%~1"
ECHO ________________________________________________________________________
%pathToFLAC% -t %1
REM If an error code has been returned increase the error counter
IF ERRORLEVEL 1 (
SET /A noErrors+=1
ECHO %1 [T]>>"%pathForFails%flac-113-failed.txt"
ECHO.
ECHO File failed testing.
) ELSE (
REM Encode the file
ECHO.
ECHO Encoding: "%~1"
ECHO ________________________________________________________________________
IF NOT EXIST %dstf% MKDIR %dstf%
%pathToFLAC% %flacOptions% -V -f -o "%dst%" %1
REM If an error code has been returned increase the error counter
IF ERRORLEVEL 1 (
SET /A noErrors+=1
ECHO %1 [E]>>"%pathForFails%flac-113-failed.txt"
ECHO.
ECHO File failed encoding.
IF EXIST "%dst%" DEL "%dst%"
) ELSE (
SET /A noEncoded+=1
CALL :IncreaseDestinationBytes "%dst%"
CALL :IncreaseSourceBytes %1
ECHO %1>>"%pathForSuccess%flac-113-successful.txt"
)
)
)
ECHO.
ECHO.
REM Increase file counter
SET /A noProcessed+=1
GOTO:EOF

REM ==========================================
REM ReportFiles : List the files that failed
REM ==========================================
:ReportFiles
ECHO.
ECHO Files that failed:
ECHO.
TYPE "%pathForFails%flac-113-failed.txt"
REM Delete the temporary file if not required, or add footer if keeping
IF [%retainListOfFailedFiles%] EQU [1] (
REM ECHO.>>"%pathForFails%flac-113-failed.txt"
REM ECHO List created at %DATE% %TIME%>>"%pathForFails%flac-113-failed.txt"
) ELSE (
DEL "%pathForFails%flac-113-failed.txt"
)
ECHO.
GOTO:EOF

REM =====================================================
REM NoParams : neither a file or folder has been passed
REM =====================================================
:NoParams
ECHO To run this script, please pass a valid file or folder as a parameter.
ECHO.
ECHO Press any key to exit
PAUSE >NUL
GOTO:EOF

:IncreaseSourceBytes
SET /A srcSize+=%~z1
GOTO:EOF

:IncreaseDestinationBytes
SET /A dstSize+=%~z1
GOTO:EOF

Jose Hidalgo
THANK YOU, OH THANK YOU Synthetic Soul !!! biggrin.gif

I'll report my test results soon.

Cheers,

Jose
kmitch
I'm in the process of writing a VB Script that performs steps similar to those in flac-113.bat. It's basically for my own use... but I'm willing to share.

Is there any interest out there for this?

-K
probedb
QUOTE(kmitch @ Feb 4 2008, 02:11) *

I'm in the process of writing a VB Script that performs steps similar to those in flac-113.bat. It's basically for my own use... but I'm willing to share.

Is there any interest out there for this?

-K


If it can do the same job without falling over on files with certain characters in them I'd be interested.

It's not the script the problem it's just the DOS scripting that makes certain characters in filenames invalid and unable to be processed but your script would sort this?
kmitch
QUOTE(probedb @ Feb 4 2008, 05:52) *

If it can do the same job without falling over on files with certain characters in them I'd be interested.

It's not the script the problem it's just the DOS scripting that makes certain characters in filenames invalid and unable to be processed but your script would sort this?


Which characters in particular? I'll test with them.
Synthetic Soul
They shouldn't pose an issue for you. Characters like percent, caret, and brackets can cause problems in batch files (or at least mine) if not escaped properly.

I for one would be happy to see a script to supercede flac-113.bat. smile.gif

I really should use VBScript more for my scripts, I really don't know why I don't. IIRC the WSH is built-in to all XP machines.
probedb
QUOTE(kmitch @ Feb 4 2008, 11:29) *

QUOTE(probedb @ Feb 4 2008, 05:52) *

If it can do the same job without falling over on files with certain characters in them I'd be interested.

It's not the script the problem it's just the DOS scripting that makes certain characters in filenames invalid and unable to be processed but your script would sort this?


Which characters in particular? I'll test with them.


I'll try and remember to check this evening smile.gif I believe it's things like single quotes.
Jose Hidalgo
Thanks in advance kmitch (with credits to synthetic soul also of course).
kmitch
I'll try to type up some documentation this evening and post the script. Just wanted to set a few expectation with this post, though... The script is not really a direct replacement of the batch files. It won't really handle dropping items on it and have it process them. It's more of a command line script with parameters that allows processing a directory or a file list.

-K
kmitch
Here's the document I typed up about the functionality:
---
Re-FLACer v1.0

Purpose:
I had a need. I wanted something that could help me handle my FLAC
library. Verify that the files were not corrupt, Re-Encode them if a
new version of FLAC came out that had better compression, decode them
back to a WAV file, or allow me to easily convert to MP3s for portable
devices.

I considered a VB GUI app, possibly a VB console app... but decided that
I wanted the freedom of a VB Script. The code isn't compiled, and if I
need something for a special situation, this provides an easy way to
modify the code.

There are other applications out there, probably with more features, but
for simplicty and ease of use, I rolled my own.

Basic use:
You set up a config file with the values you want to use, and then run
the program (optioanlly with command line parameters).

Some of the required information is:

Mode
The program can be run in one of the following modes at a time:
Encode - The program looks for .WAV files and will encode them
using .FLAC

Decode - The program looks for .FLAC files and will decode them to
.WAV

MP3 - The program looks for .FLAC files, intermediately decodes
them to .WAV, then uses lame to encode the .WAV to .MP3
and removes the .WAV file

ReFLAC - The program looks for .FLAC files and re-encodes them to
.FLAC

Test - The program looks for .FLAC and tests the files for
validity

Input
There are three choices (only 2 have been coded thus far)
Directory - Command Line Parameter DIR. If used, the program will
look in this directory and all subdirectories for
files and perform the Mode action on those files

File List - Command Line Parameter FILELIST. formatted as 1 file
per line with full path and filename, the program will
iterate through each file and perform the mode action.

File - Command Line Parameter will be FILE. As this is the
least important option for me, it hasn't been coded
yet. It will allow the program t act on an individual
file.

A little discussion on the other command line/config file parameters:

CONFIG
The program always expects a configuration file (Re-FLACer.cfg) to be
present in the script directory. This config file is read first, then
any command line options are processed in the order they appear on the
command line. You can load another config file from the command line
that can override any values that exist in the original config file, or
appear on the command line earlier than the CONFIG parameter.


LOGFILENAME
The program will log all of it's information to the LOGFILENAME in the script directory

TARGETDIR
If this parameter is left blank, the action will occur the the original
file's directory. If this value is populated, the resulting directory
(if any) will be determined based on the type of Input:

Directory - The Original directory will be replaced by TARGETDIR as
the root, any subdirectories in the Directory will be
created in the TARGETDIR.

File List - The root directory of the file in the list will be placed
in the TARGETDIR. For example, given the file:
X:\Music\ZZ Top\Greatest Hits\Legs (Remix Version).flac
And a TARGETDIR of G:\Target, the file will be placed in:
G:\Target\Music\ZZ Top\Greatest Hits\Legs (Remix Version).flac

File - The file will be placed in the TARGETDIR

FLAC Related
FLACPROGRAM
The full path and filename to flac.exe

METAFLACPROGRAM
The full path and filename to metaflac.exe

VERSIONSKIP
Skip the file for processing if the version of the FLACPROGRAM is the
same as the version of the FLAC file being processed.

Tag Related
TAGPROGRAM
The full path and filename to tag.exe

REMOVEID3V2
If this has a value of Y, ID3v2 tags will be removed prior to the
operations. This only occurs if the TARGETDIR parameter is left
blank.

Lame Related
LAMEPROGRAM
The full path and filename to lame.exe

LAMEPARAMETERS
The lame parameters that should be used when encoding to MP3

The following files all reside in the script directory, and are written
to based on the associated KEEP* parameter

COMPLETEDLIST (KEEPCOMPLETED=Y or N)
The list of files that were processed successfully

ERRORLIST (KEEPERROR=Y or N)
The list of files that did not complete

SKIPPEDLIST (KEEPSKIPPED=Y or N)
The list of files that were skipped because of the VERSIONSKIP
parameter.


External Programs
This program is just a wrapper around functionality available in other
programs. It makes use of the following executables:

FLAC v1.2.1
Makes use of flac.exe and metaflac.exe, these programs can be obtained from
http://flac.sourceforge.net/ on the Download page, click on the link to
download FLAC for Windows (command-line tools only).

Tag v2.0.52
Makes use of Tag to identify and remove ID3v2 tags. This program can be
obtained from http://synthetic-soul.co.uk/tag/

Lame v3.97
LAME is an MPEG Audio Layer III (MP3) encoder licensed under the LGPL.
It can be downloaded from http://lame.sourceforge.net


I also wanted to thank Synthetic Soul (http://www.synthetic-soul.co.uk/)
for his work on flac-113.bat, and the other related batch files. They
helped me determine what I wanted the script to do.
---

I don't really have a place to host this code, and it looks like I can't add an attachment to this post. I can post the VBScript and the config file in code sections, but don't think that's the best option. Is anyone aware of a place I can post the ZIP file (it's only about 10K).
Jose Hidalgo
You can try a hosting service like rapidshare, or I can host it if you mail it to me. Up to you.
kmitch
The file has been posted on RapidShare
RapidShare Link to Re-FLACer_1_0.zip

Synthetic Soul
That all sounds great. I look forward to taking a look.

QUOTE(kmitch @ Feb 5 2008, 00:15) *
I don't really have a place to host this code, and it looks like I can't add an attachment to this post. I can post the VBScript and the config file in code sections, but don't think that's the best option. Is anyone aware of a place I can post the ZIP file (it's only about 10K).
You can zip the scripts and upload them to the Uploads forum here. There are temporary hosts but they tend to remove the files after a time, or if there is not enough traffic. The Uploads forum is the perfect place for this.

Edit: Oops, must have missed the last page of posts. blush.gif
Demetris
Thanks for this script, kmitch! :-) I run a quick test (a few dozen FLAC files) and it seems to work fine.

A couple of questions:
  • Does it use --best by default for FLAC? Can we change this? In general, can we pass parameters to flac.exe?
  • Does it use --verify?

And a couple of ideas:
  • I would like to be able to save the log files in dedicated directories for each batch job, named after the date and also the version of flac used. E.g.: 20080205a-flac121
  • For hosting, you could use Google Pages if you have a Google account (or even Google Code, if you think its infrastructure could be useful in this case) -- or, if you prefer something like Rapidshare, I know there are services less annoying than Rapidshare, but I can't remember any names now off the top of my head :-)
kmitch
QUOTE(Demetris @ Feb 5 2008, 08:25) *

A couple of questions:
  • Does it use --best by default for FLAC? Can we change this? In general, can we pass parameters to flac.exe?
  • Does it use --verify?

The FLAC command currently uses -f -8 for encoding, -f -d for decoding, and -t for testing, I'll look into moving these into the config file/command line.
QUOTE(Demetris @ Feb 5 2008, 08:25) *
  • I would like to be able to save the log files in dedicated directories for each batch job, named after the date and also the version of flac used. E.g.: 20080205a-flac121

I'll look into adding a Log Directory config/command line parameter that can use variables (Mode, Date, etc.).

Thanks for the suggestions.
kmitch
A new version of Reflacer has been posted to Google Code. Here's the link to the project:

http://code.google.com/p/reflacer/

The following changes have been made in this version:
  • Changed name from Re-FLACer
  • Fixed bug when directory to be created was more than 1 level deep
  • Added wrappers around FileSystemObject calls
  • Moved code around to make it easier to read
  • Added LOGDIR command line/config file parameter (Demetris)
  • Added single File Processing (FILE parameter)
  • Added FLAC command line parameters (Demetris)

The .txt file with documentation has also been updated.
Demetris
Thanks again, kmitch! and congrats on the project page!

Another two ideas; they are not suggestions -- just ideas! :-)
  • Create automatically the specified TargetDir if it does not exist -- or maybe add something like this to the comment: "Destination directory must exist"
  • When a TargetDir is specified, ability to copy over non-audio files, perhaps with some filter. E.g.: folder.jpg;*.log;*.cue, or: *.*, or *.jpg

And a small problem in the MP3 mode:
  • It seems tag cannot write ID3v2 tags, which means that a lot of information may be lost (like Unicode strings or custom fields) -- but maybe there is not much you can do about this; are there command-line taggers for Windows that can write ID3v2.4 or ID3v2.3?
kmitch
QUOTE(Demetris @ Feb 7 2008, 10:02) *
  • Create automatically the specified TargetDir if it does not exist -- or maybe add something like this to the comment: "Destination directory must exist"

With version 1.01, the TargetDir will be created if it doesn't exist.

QUOTE(Demetris @ Feb 7 2008, 10:02) *
  • When a TargetDir is specified, ability to copy over non-audio files, perhaps with some filter. E.g.: folder.jpg;*.log;*.cue, or: *.*, or *.jpg

I'll have to think about how to implement this one and make it flexible enough.

QUOTE(Demetris @ Feb 7 2008, 10:02) *
    And a small problem in the MP3 mode:
    [list]
  • It seems tag cannot write ID3v2 tags, which means that a lot of information may be lost (like Unicode strings or custom fields) -- but maybe there is not much you can do about this; are there command-line taggers for Windows that can write ID3v2.4 or ID3v2.3?

I don't know of another command line tagger that could be used. The nice thing about Tag is that it allows copying the tags from FLAC to MP3. I can parse the tags from FLAC but this would require some additional logic, and probably an additional TagMapping file... if I need to use a different executable.
probedb
Just used this for the first time and it's worked except there's something wrong with the directory creation logic. I have:

' Top level directory that contains the files to process
Dir=G:\Temp\_music
'
' Top level destination directory
TargetDir=G:\Temp\_music\_encoded

It's created the _encoded directory and the album directory down to

G:\Temp\_music\_encoded\_encoded\_encoded\_encoded\_encoded\_encoded\_encoded\_encoded\_encoded\_encoded\_encoded\_encoded\_encoded\_encoded\_encoded\_encoded\_encoded\_encoded\_encoded\_encoded\_encoded\_encoded\_encoded\_encoded

I think that's roughly twice the number of tracks!?
kmitch
QUOTE(probedb @ Feb 7 2008, 16:00) *

Just used this for the first time and it's worked except there's something wrong with the directory creation logic. I have:

' Top level directory that contains the files to process
Dir=G:\Temp\_music
'
' Top level destination directory
TargetDir=G:\Temp\_music\_encoded

It's created the _encoded directory and the album directory down to

G:\Temp\_music\_encoded\_encoded\_encoded\_encoded\ ...

I think that's roughly twice the number of tracks!?


I had only tested with the TARGETDIR in a separate parent directory, not nested within the DIR... I'll try to recreate the issue, and take a look at the code...

Edit: That's not going to work by specifying a DIR, because the program is recursively going through the directories and looking for files, you'd have to run using a filelist. If it finds files, it processes them... This really should have kicked an error out to you saying that the the TARGETDIR cannot be a child of DIR.
kmitch
QUOTE(kmitch @ Feb 7 2008, 12:56) *

QUOTE(Demetris @ Feb 7 2008, 10:02) *
  • Create automatically the specified TargetDir if it does not exist -- or maybe add something like this to the comment: "Destination directory must exist"

With version 1.01, the TargetDir will be created if it doesn't exist.


I was mistaken. the TargetDir would not be created if it did not exist. I have corrected this in the code, and it will be in the next version.
probedb
QUOTE(kmitch @ Feb 8 2008, 03:18) *

Edit: That's not going to work by specifying a DIR, because the program is recursively going through the directories and looking for files, you'd have to run using a filelist. If it finds files, it processes them... This really should have kicked an error out to you saying that the the TARGETDIR cannot be a child of DIR.


Cheers that makes sense! I'll use a dir outside the other one smile.gif

Out of interest what happens if they're the same directory? Will it try and copy files onto themselves or behave as the .bat file did and rename then reencode if required? I did like the ability to be able to give it a directory and just end up with a set of updated FLAC files.
kmitch
QUOTE(probedb @ Feb 8 2008, 08:41) *

Out of interest what happens if they're the same directory? Will it try and copy files onto themselves or behave as the .bat file did and rename then reencode if required? I did like the ability to be able to give it a directory and just end up with a set of updated FLAC files.


It will issue the command
CODE
flac.exe --force --best --verify filename.flac

flac will create a temporary file, and re-encode the file to the original filename. The script can (based on the VersionSkip config file/command line parameter) also skip .flac files that are already encoded with the flac.exe version.

If a TargetDir isn't specified, you can also Decode, Encode, or MP3 to the same directory.
kmitch
I've just released Reflacer v1.02, you can find it at http://code.google.com/p/reflacer/

Here are the changes that are included in this version:

* Fixed bug with the Logo being written to the screen in an error state
* If using DIR and TARGETDIR, a list of files that are in TARGETDIR but not in DIR will be logged
* Added COPYFILEMASKS command line/config file parameter (Demetris)
* Will now create TARGETDIR if it does not exist (Demetris)
* Will now handle TARGETDIR being a child of DIR (will not recurse TARGETDIR) (probedb)
* When specify variables for LOGDIR, may use ^ instead of % (easier in batch files)
* Fixed bug with displaying TARGETDIR parameter
* Fixed bug that occurred when decoding a flac file failed in MP3 mode

I've also added ReflacerTest, that includes some sample WAV files (one that is corrupt, one with an ID3v2 tag) and a batch file to test how Reflacer works.
Demetris
Thanks for the enhancements, kmitch!
jamesbaud
I just started using this program, and it's great. I have a large library of FLAC files and a dual core machine. It's taking a long time (ongoing as I write) but 1 core is idle.

I have one suggestion, from another thread, "FLAC for core duo"

http://www.hydrogenaudio.org/forums/index....st&p=548292

Can you add the ability to call multiple instances of FLAC for multiple core machines, the way foobar does?
kmitch
QUOTE(jamesbaud @ Feb 21 2008, 11:34) *

I just started using this program, and it's great. I have a large library of FLAC files and a dual core machine. It's taking a long time (ongoing as I write) but 1 core is idle.

I have one suggestion, from another thread, "FLAC for core duo"

http://www.hydrogenaudio.org/forums/index....st&p=548292

Can you add the ability to call multiple instances of FLAC for multiple core machines, the way foobar does?


As far as I know, it can't be easily done in VBScript. VBScript doesn't allow for threading, I'd also have to rewrite some of the logic used for the temporary files that are created during the process, and it would complicate logging a bit.

I do have an alternative for you, though. I would create a second directory to place the script in, and copy the neccessary files to that directory (you can leave the executables where they are). In DOS, go to the directory that you want to work against, and type
CODE
dir /b /s *.flac > files.txt
you can then split this file into 2 lists of files. Then you can run Reflacer twice at the same time with different file lists.

It's not the most elegant solution, but it's the best I can offer without moving to a compiled executable using VB .Net or doing something similar to what is outlined below.

Once I finish with the testing in this version and get it out the door, I'll look at making the temporary files that are being used by the process a little more run-centric so you can use the same .vbs to run multiple times.

It looks like I can determine the number of processors at runtime:
CODE
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")


Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOS in colOSes
  Wscript.Echo "Computer Name: " & objOS.CSName

  Wscript.Echo "Operating System"
  Wscript.Echo "  Caption: " & objOS.Caption 'Name
  Wscript.Echo "  Version: " & objOS.Version 'Version & build
  Wscript.Echo "  BuildNumber: " & objOS.BuildNumber 'Build
  Wscript.Echo "  BuildType: " & objOS.BuildType
  Wscript.Echo "  OSProductSuite: " & objOS.OSProductsuite 'OS Product suite
  Wscript.Echo "  OSType: " & objOS.OSType
  Wscript.Echo "  OtherTypeDescription: (2003 Server R2 release only)" & objOS.OtherTypeDescription
  WScript.Echo "  ServicePackMajorVersion: " & objOS.ServicePackMajorVersion & "." & _
   objOS.ServicePackMinorVersion

Next

Wscript.Echo "Processors"

Set colCompSys = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objCS in colCompSys
  WScript.Echo "  NumberOfProcessors: " & objCS.NumberOfProcessors
Next

Set colProcessors = objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objProcessor in colProcessors
  WScript.Echo "  Manufacturer: " & objProcessor.Manufacturer
  WScript.Echo "  Name: " & objProcessor.Name
  WScript.Echo "  Description: " & objProcessor.Description
  WScript.Echo "  ProcessorID: " & objProcessor.ProcessorID
  WScript.Echo "  Architecture: " & objProcessor.Architecture
  WScript.Echo "  AddressWidth: " & objProcessor.AddressWidth
  WScript.Echo "  DataWidth: " & objProcessor.DataWidth
  WScript.Echo "  Family: " & objProcessor.Family
  WScript.Echo "  MaximumClockSpeed: " & objProcessor.MaxClockSpeed
Next


I may be able to create a way to divy up the files between 2 runs and kick them both off from a single command. You'd still have 2 log files, etc... but would make the most use of your dual core/quad core processor.

BTW... I'm doing my final testing on a new version that adds quite a bit of functionality to re-encoding to MP3... more info to come on that.

-K
ludwig
sorry kmitch, but there's a problem with 1.2.1 on 24 bits files. Could it be possible to encore everything but 24 bits with 1.2.1, and stay with 1.2.0 for 24 bits files ?
Regards
jamesbaud
QUOTE(kmitch @ Feb 21 2008, 17:41) *

I do have an alternative for you, though.

Thanks for the tip.
QUOTE

Once I finish with the testing in this version and get it out the door, I'll look at making the temporary files that are being used by the process a little more run-centric so you can use the same .vbs to run multiple times.

I look forward to the new version. In addition to being able to set target directories and destination directories, would it be possible to set a temp directory for the temp files?
QUOTE

BTW... I'm doing my final testing on a new version that adds quite a bit of functionality to re-encoding to MP3... more info to come on that.

This sounds exciting. Regarding MP3 encoding, as someone pointed out earlier in the thread, Tag does not support ID3v2 tags, so those don't get copied over from the FLAC tags. After a batch encode, I have to open up MP3Tag to correct the tags. I hope your new version can help to address this.

Thx again for a great tool!
jamesbaud
QUOTE(kmitch @ Feb 7 2008, 10:56) *

I don't know of another command line tagger that could be used. The nice thing about Tag is that it allows copying the tags from FLAC to MP3. I can parse the tags from FLAC but this would require some additional logic, and probably an additional TagMapping file... if I need to use a different executable.


Check out this thread, "Windows mp3/id3 command line tagger?"
Maybe it could be of some use to you.

http://www.hydrogenaudio.org/forums/index....st&p=326750
kmitch
QUOTE(jamesbaud @ Feb 22 2008, 12:14) *

[In addition to being able to set target directories and destination directories, would it be possible to set a temp directory for the temp files?


In the next version, a Temp directory will be created under the Script Directory automatically. All files that are used by the processes will be in that directory.

QUOTE

This sounds exciting. Regarding MP3 encoding, as someone pointed out earlier in the thread, Tag does not support ID3v2 tags, so those don't get copied over from the FLAC tags. After a batch encode, I have to open up MP3Tag to correct the tags. I hope your new version can help to address this.


I also looked at using ID3 Mass Tagger, but it didn't provide what I wanted. I didn't want to have issues with characters that don't work well in a command line. ID3 Mass Tagger didn't include a way to pull tags in from a file.

With the new version, I'll still be using Tag to remove ID3v2 tags from FLAC files, and you'll gave the choice to use it to copy tags from FLAC to MP3, or to use metamp3 (http://www.hydrogenaudio.org/forums/index....showtopic=49751). When using metamp3, the script will export each tag to a separate file, and then all at once use those files to tag the MP3. I've also built a mapping file (Reflacer.tag) that you can use to map the FLAC tags to the MP3 frames.

The next version also includes the ability to add images to the MP3 either from a file in the original directory, or you can pull it from the FLAC file (you provide a list of sources, and it checks until it finds a match). Only one image will be used to tag the MP3.

I've also written a little utility to resize the image (if you want to) prior to tagging the MP3. Some hardware only supports images in tags up to a certain resolution, this should take care of that.

The only thing I'm working on now is to create additional ReflacerTest scenarios to cover the new functionality... this helps me regression test the script to make sure I haven't broken anything along the way.

-K
kmitch
A new version of Reflacer has been released. I've also created a new topic for Reflacer discussion here:

http://www.hydrogenaudio.org/forums/index....showtopic=61511

Here are the changes for this version:

02/22/2008 v1.03
  • Added support for metamp3 for copying tags
  • Added METAMP3PROGRAM & METAMP3PARAMS command line/config file parameter
  • New file Reflacer.tag, used to map FLAC tags to MP3
  • Added TAGGER command line/config file parameter, choose between Tag or metamp3
  • The %ScriptDir% variable can now be used for any command line/config file parameters
  • Added ability to use a file or FLAC picture in MP3 conversion
  • IMAGESOURCE parameter allows hierarchy to use when searching for an image
  • Introduction of imgResize.exe (simple VB app to resize an image file)
  • RESIZEIMAGE parameter turns imgResize on or off
  • Added IRPROGRAM & IRPARAMETERS to support imgResize
  • Fixed potential error where path to the programs contained a space
  • Temp directory is now used for all temporary processing files
  • Code Change - all variables have been switched to Hungarian notation
-K
jamesbaud
Wow! you're fast. I'll try it out. Thx.
Jose Hidalgo
QUOTE(ludwig @ Feb 22 2008, 02:14) *

sorry kmitch, but there's a problem with 1.2.1 on 24 bits files.

Hi ludwig, can you be more specific please ? I'd like to know more about that. Thank you.
kmitch
QUOTE(ludwig @ Feb 21 2008, 20:14) *

sorry kmitch, but there's a problem with 1.2.1 on 24 bits files. Could it be possible to encore everything but 24 bits with 1.2.1, and stay with 1.2.0 for 24 bits files ?
Regards


Is the problem only with one of the functions? Just Decoding, Encoding, Testing? Is Metaflac.exe affected, or just flac.exe?

Depending on what it impacts, I may be able to add some logic around an alternate FLAC program. I'd aso need a sample file to play with.

I would really like to take the discussion here:
http://www.hydrogenaudio.org/forums/index....showtopic=61511
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.