Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Command Line encoding (Read 5564 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Command Line encoding

I have always used a frontend because they're easy, but now I want to try using the command line to encode a WAV file to FLAC. I've read the who documentation thing on the FLAC website, but I still don't understand. Can somebody give me a noob walk through type deal? I can input the path to the FLAC executive and input the compression rate, but after that I'm lost.

Command Line encoding

Reply #1
The easiest command line you can do is:

Code: [Select]
"C:\path\to\flac.exe" "C:\other\path\to\input.wav"

This will use the default compression setting (-5) and produce the file "C:\other\path\to\input.flac"

If you want to set a compression setting (-0 to -8) use:

 
Code: [Select]
"C:\path\to\flac.exe" -6 "C:\other\path\to\input.wav"

If you want to specify the output file's name use:
 
   
Code: [Select]
"C:\path\to\flac.exe" -8 "C:\other\path\to\input.wav" -o "C:\another\path\to\output.flac"

If you want to verify the encoded file as you encode use:

   
Code: [Select]
"C:\path\to\flac.exe" -4 -V "C:\other\path\to\input.wav" -o "C:\another\path\to\output.flac"


Finallly, I would recommend putting flac.exe in a folder in your PATH, like your windows folder.  This means that you can then navigate to the source WAVE's folder and use something like:

   
Code: [Select]
flac.exe -4 -V input.wav -o output.flac

i.e.: you don't need to always specify the path to flac.exe.  If you are in the source WAVE's folder you don't need to specify the full path to the source file, or destination file if you specify one (using the -o switch).

Edit:  Sorry, I forgot about tagging.  If you want to set tags when encoding use the format:

Code: [Select]
-T "TAGNAME=VALUE"

E.g.:

   
Code: [Select]
flac.exe -6 -V -T "ARTIST=Pixies" -T "ALBUM=Doolittle" input.wav -o output.flac
I'm on a horse.

Command Line encoding

Reply #2
Thanks for the help, but I can only seem to get it to work if the path to flac.exe is C:

If I put the flac.exe on my desktop and enter the path to it, I get an error saying that "Documents" isn't a valid something.

Wouldn't this be the path to the flac.exe if on my desktop?

Code: [Select]
C:\Documents and Settings\<user name>\Desktop\flac.exe

Command Line encoding

Reply #3
Notice that my example uses double quotes.

If your path - the path to flac or the source file - has spaces in you need to surround it in quotes.

I would seriously suggest that you stick flac.exe in your Windows directory though, so you can just use:

Code: [Select]
flac.exe -V6 input.wav

NB: Please note the addition of tagging to the suggestions above.
I'm on a horse.

Command Line encoding

Reply #4
Just one more question. How do you batch encode? Basically I can encode and tag single files, but not a whole folder full of WAVs. I want to encode a whole folder full and output to another folder using the same exact input name, but with the extension changed to .flac.

Command Line encoding

Reply #5
Navigate to the source folder and use:

Code: [Select]
FOR %G IN (*.wav) DO "C:\Path\To\flac.exe" -6 -V "%G" -o "C:\Path\To\Output\%~nG.flac"


Remember to change "C:\Path\To\Output" to the real output directory.
I'm on a horse.

Command Line encoding

Reply #6
I'm not sure if I'm putting it right, but it gives me an error stating, "ERROR: -o/--output-name cannot be used with multiple files"

Command Line encoding

Reply #7
Can you post the whole ouput from the console?

What OS are you using?
I'm on a horse.

Command Line encoding

Reply #8
I'm using Windows XP SP2.

This is what I type in the command line. It's probably wrong though since I'm like two days into actually using the Command Line for the first time.

Code: [Select]
"C:\Documents and Settings\<user name>\Desktop\flac.exe" "D:\MUSIC BACK-UP (WAV)\Nightrage - Sweet Vengeance" FOR %G IN (*.wav) DO "C:\Documents and Settings\<user name>\Desktop\flac.exe" -8 -V "%G" -o "D:\MUSIC BACK-UP (FLAC 1.1.4)\Nightrage - Sweet Vengeance\%~nG.flac"


First part is the path to flac.exe. The second part is the path to the music files in WAV format. The third part is what you said for me to input. The fourth part is the path to flac.exe. The fourth part is the compression setting and to verify the encode. The last part is the output location for the FLAC files.

Now I realize why I stayed away from using command line forever. Just trying to expand what I can do on a computer and I might as well start by doing it with something I do all the time (encode audio files).

Command Line encoding

Reply #9
The line I provided was the whole thing - don't preceed it with the path to FLAC. I.e. only:

Code: [Select]
FOR %G IN (*.wav) DO "C:\Documents and Settings\<user name>\Desktop\flac.exe" -6 -V "%G" -o "D:\MUSIC BACK-UP (FLAC 1.1.4)\Nightrage - Sweet Vengeance\%~nG.flac"


If you can't navigate to "D:\MUSIC BACK-UP (WAV)\Nightrage - Sweet Vengeance" before executing the line above then you can run the line below from any directory:

Code: [Select]
FOR "D:\MUSIC BACK-UP (WAV)\Nightrage - Sweet Vengeance" %G IN (*.wav) DO "C:\Documents and Settings\<user name>\Desktop\flac.exe" -6 -V "%G" -o "D:\MUSIC BACK-UP (FLAC 1.1.4)\Nightrage - Sweet Vengeance\%~nG.flac"


NB: In order to easily execute commands from within a directory 1. I store my EXEs in a folder in PATH (like your Windows folder) and 2. I use a little app called Clickie.  This adds an item to any folder's context menu, "Open MS-DOS Prompt", which I find very, very useful.  IIRC there is an XP power toy that does the same thing.  Ah, yes, here.
I'm on a horse.

Command Line encoding

Reply #10
Entering the first line as is gives me nothing at all. Not even an error or anything shows up. It just drops down to another line for another command.

Entering the second line as is gives me an error that states, "D:\MUSIC BACK-UP (WAV)\Nightrage - Sweet Vengeance" was unexpected at this time."

Command Line encoding

Reply #11
When running the first line are you actually running it from within "D:\MUSIC BACK-UP (WAV)\Nightrage - Sweet Vengeance"?

Sorry, the second line is wrong, it should be:

Code: [Select]
FOR %G IN ("D:\MUSIC BACK-UP (WAV)\Nightrage - Sweet Vengeance\*.wav") DO "C:\Documents and Settings\<user name>\Desktop\flac.exe" -6 -V "%G" -o "D:\MUSIC BACK-UP (FLAC 1.1.4)\Nightrage - Sweet Vengeance\%~nG.flac"

I'm used to running it recursively, which would use the syntax:

Code: [Select]
FOR /R "D:\MUSIC BACK-UP (WAV)\Nightrage - Sweet Vengeance" %G IN (*.wav) DO "C:\Documents and Settings\<user name>\Desktop\flac.exe" -6 -V "%G" -o "D:\MUSIC BACK-UP (FLAC 1.1.4)\Nightrage - Sweet Vengeance\%~nG.flac"
I'm on a horse.

Command Line encoding

Reply #12
Thank you for all your help Synthetic Soul. It did take me two times to get it to work since I misspelled a bunch of stuff, but got it to work eventually.

Command Line encoding

Reply #13
How would you re-encode flac to a newer version of flac using the command line?

Command Line encoding

Reply #14
You're welcome.

FLAC can now (since 1.1.3 IIRC) accept FLAC files as input, so the easy answer is:

Code: [Select]
FLAC.EXE -6 -V -o output.flac input.flac

If you want to re-encode a whole bunch of files then you may want to perform the re-encoding with some verification, and may need to re-encode over the old file, if disk space is an issue.

You may be interested in a batch file I wrote when 1.1.3 came out: flac-113.bat (readme).
I'm on a horse.

Command Line encoding

Reply #15
I used your batch file and it worked perfectly. Really saved me time. It just overwrites the old flac files with the new ones in the input folder, correct?

Command Line encoding

Reply #16
The source FLACs are replaced by the new FLACs, but it's not just a simple overwrite.

The new file should only get overwritten if it has passed testing and the re-encode was a complete success.  I.e.: the batch file will only encode a sound source file, and then it encodes to a new file, verifies while writing, and only when happy that the new file is OK moves the new file over the old.
I'm on a horse.