Hydrogenaudio Forums

Lossy Audio Compression => Ogg Vorbis => Ogg Vorbis - Tech => Topic started by: vacoradio on 2006-02-03 18:09:01

Title: oggenc2 batch file?
Post by: vacoradio on 2006-02-03 18:09:01
Hello everyone!!

I have a little problem, I have about 20 shows that are in Flac format that I would like to convert to Ogg format. I would rather not type all the file names or drag each show to the executable.

so I would like to write a batch file for windows/dos to do this. but i am having some problems with it. I have tried a few different routes, wildcards, redirecting output, piping, and none have seemed have worked, i even tried so unix type commands(i have the gnu windows port).

Here are some examples of what i tried:

Code: [Select]
oggenc2 *.flac

dir /b > oggenc2

dir /b | oggenc2

ls *.flac | cat > oggenc2

ls *.flac > oggenc2

ls *.flac | cat > files.txt
files.txt > oggenc2


i dont knwo what else to try to convert multiple files with out drag-n-droping or typing all the file names on the command line.

Any help or idea would be great!!

Thank YOU!!!
Title: oggenc2 batch file?
Post by: hangman on 2006-02-03 18:20:26
How about:

for %%f in (*.flac) DO (oggenc2.exe "%%f" "%%~nf.ogg")
Title: oggenc2 batch file?
Post by: Synthetic Soul on 2006-02-03 18:40:42
It looks like you were attempting to pipe from FLAC to OGGENC.

The format there would be:

Code: [Select]
FLAC --decode --stdout file.flac | OGGENC2 - file.ogg

... but as hangman subtely points out, OGGENC will take FLAC as an input file, so no need to pipe decoded data.

NB: If you have your files tagged and want to copy over the tags you may do best to use foobar, or maybe use Tag as a second process, e.g.:

Code: [Select]
FOR %%f IN (*.flac) DO (OGGENC2.EXE "%%f" "%%~nf.ogg" && TAG.EXE --fromfile "%%f" "%%~nf.ogg")
Title: oggenc2 batch file?
Post by: john33 on 2006-02-03 19:56:45
As mentioned above, it will take the FLAC files as direct input, and will also copy the FLAC tags.
Title: oggenc2 batch file?
Post by: Synthetic Soul on 2006-02-03 22:31:16
I did wonder.  That's cool.
Title: oggenc2 batch file?
Post by: gameplaya15143 on 2006-02-05 03:09:45
is there any reason to even bother with a batch file?

this task would be much easier IMO with dBpowerAMP or foobar2000
Title: oggenc2 batch file?
Post by: Deep_Elem on 2006-02-05 05:11:12
Or try out Speek's multi-frontend (http://members.home.nl/w.speek/multi.htm) to make the batchfile for you.
Title: oggenc2 batch file?
Post by: Synthetic Soul on 2006-02-05 09:19:09
With a batch file you can just drag a folder onto the icon (or a shortcut) and all FLAC files within the folder will be converted, with no middle-tier overhead.

I don't see how you can get easier than that.

Come to think of it, oggdropXPd (http://www.rarewares.org/ogg.html) springs to mind.
Title: oggenc2 batch file?
Post by: Deep_Elem on 2006-02-06 05:22:30
Dang, I should have mentioned oggdropxpd - an excellent suggestion!
Title: oggenc2 batch file?
Post by: Deep_Elem on 2006-02-07 18:17:17
If you are still interested in the batchfile idea, here's some code for you. Put the batchfile inside the folder that contains all your flac folders and it will recursively go through each folder and convert the flac files to ogg, without deleting:



@echo off
for /D %%D in (*.*) do call :convert "%%D"

vorbisgain -ar "*.ogg"
goto :EOF

:convert
pushd "%1"
for %%F in (*.flac) do oggenc2 -q6 -p4 "%%F"
popd


After converting, this will apply album replaygain to each folder recursively if you have vorbisgain.exe in your system path. Delete the vorbisgain line if you don't need it. Note that it uses quality 6 (-q6) and adds 4KB of padding (-p4) for tags. You can change that, of course. If your flac files are already fully tagged and replaygained you probably won't need the padding.

Make sure none of your flac files have an exlamation mark in the file name as this will cause oggenc2.exe to skip over it.

Hope this helps. 
Title: oggenc2 batch file?
Post by: manuelator on 2006-02-10 18:14:03
Nice batch, but you know how to do with subfolders?

Thanks
Title: oggenc2 batch file?
Post by: Deep_Elem on 2006-02-10 23:08:49
Yes it can be modified to put the output files into subfolders. Where would you like the subfolders exactly? Inside each flac folder, or somewhere else?
Title: oggenc2 batch file?
Post by: VEG on 2006-02-11 10:20:53
Code: [Select]
lame --quiet --decode "%~dpn1.mp3" - | oggenc -q0 -o "%~dpn1.ogg" -
Isn't working correctly with rarewares build of lame:(
Code: [Select]
c:\Temp>lame --quiet --decode test.mp3 - | oggenc -o test.ogg -
Opening with wav module: WAV file reader
Encoding standard input to
        "test.ogg"
at quality 3,00
       [  1,9%] [24m22s remaining] |/

Done encoding file "test.ogg"

       File length:  3m 48,0s
       Elapsed time: 0m 28,0s
       Rate:         8,1726
       Average bitrate: 107,5 kb/s
Title: oggenc2 batch file?
Post by: john33 on 2006-02-11 11:22:43
It's the progress indicator that's wrong, the output is correct.
Title: oggenc2 batch file?
Post by: VEG on 2006-02-12 10:34:58
Quote
It's the progress indicator that's wrong, the output is correct.
[a href="index.php?act=findpost&pid=363469"][{POST_SNAPBACK}][/a]

Please try to listen end of encoded file.
Title: oggenc2 batch file?
Post by: john33 on 2006-02-12 14:33:02
Yep, I detect a spike at the end of the ogg file which is not present on the original mp3, nor on the wave file produced by decoding the mp3.

Edit: On further examination, a particular ogg file has acquired an additional 11 samples at the end that are not on the mp3 file, not on the decoded mp3 file, nor are they on a decoded mp3 written as a wave file via stdout, so it doesn't, at first glance, look like lame is the offending link in this chain. Further research obviously needed!!

Edit 2: The problem is lame. When writing output via the pipe, it is attempting to rewrite the wave header at the end of file. I have confirmed this by disabling the rewrite and the resulting ogg file is of the correct length, in samples, and does not contain the glitch. I'll look further into providing a proper fix.
Title: oggenc2 batch file?
Post by: john33 on 2006-02-13 15:19:48
Quote
Yep, I detect a spike at the end of the ogg file which is not present on the original mp3, nor on the wave file produced by decoding the mp3.

Edit: On further examination, a particular ogg file has acquired an additional 11 samples at the end that are not on the mp3 file, not on the decoded mp3 file, nor are they on a decoded mp3 written as a wave file via stdout, so it doesn't, at first glance, look like lame is the offending link in this chain. Further research obviously needed!!

Edit 2: The problem is lame. When writing output via the pipe, it is attempting to rewrite the wave header at the end of file. I have confirmed this by disabling the rewrite and the resulting ogg file is of the correct length, in samples, and does not contain the glitch. I'll look further into providing a proper fix.
[a href="index.php?act=findpost&pid=363713"][{POST_SNAPBACK}][/a]

Following a quick PM exchange with Gabriel, I will be reporting this as a bug on the LAME lists. In the meantime, I will post a fixed version at Rarewares later today pending the official fix.
Title: oggenc2 batch file?
Post by: john33 on 2006-02-13 16:10:38
lame 3.97b2 and 3.98a3 fixed executables are now at Rarewares.
Title: oggenc2 batch file?
Post by: VEG on 2006-02-14 18:19:36
Thank you!
Title: oggenc2 batch file?
Post by: panther_cOY on 2015-04-15 16:33:03
Nice batch, but you know how to do with subfolders?


1) you have to remove quotation marks in PUSHD command, otherwise won't work properly
2) to encode .flacs even in subdirs of depth 2 and more, add switch /R to the 1st FOR
3) would be nice to add -o subdir\%%~fF switch to oggenc2 in order to have resulting oggs in separated (sub)dirs

@echo off
for /R /D %%D in (*.*) do call :convert "%%D"

vorbisgain -ar "*.ogg"
goto :EOF

:convert
pushd %1
for %%F in (*.flac) do oggenc2 -q6 -p4 "%%F"
popd



SimplePortal 1.0.0 RC1 © 2008-2019