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: oggenc2 batch file? (Read 20234 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

oggenc2 batch file?

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!!!

oggenc2 batch file?

Reply #1
How about:

for %%f in (*.flac) DO (oggenc2.exe "%%f" "%%~nf.ogg")

oggenc2 batch file?

Reply #2
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")
I'm on a horse.

oggenc2 batch file?

Reply #3
As mentioned above, it will take the FLAC files as direct input, and will also copy the FLAC tags.

 

oggenc2 batch file?

Reply #4
I did wonder.  That's cool.
I'm on a horse.

oggenc2 batch file?

Reply #5
is there any reason to even bother with a batch file?

this task would be much easier IMO with dBpowerAMP or foobar2000
Vorbis-q0-lowpass99
lame3.93.1-q5-V9-k-nspsytune


oggenc2 batch file?

Reply #7
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 springs to mind.
I'm on a horse.

oggenc2 batch file?

Reply #8
Dang, I should have mentioned oggdropxpd - an excellent suggestion!

oggenc2 batch file?

Reply #9
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. 

oggenc2 batch file?

Reply #10
Nice batch, but you know how to do with subfolders?

Thanks

oggenc2 batch file?

Reply #11
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?

oggenc2 batch file?

Reply #12
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

oggenc2 batch file?

Reply #13
It's the progress indicator that's wrong, the output is correct.

oggenc2 batch file?

Reply #14
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.

oggenc2 batch file?

Reply #15
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.

oggenc2 batch file?

Reply #16
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.

oggenc2 batch file?

Reply #17
lame 3.97b2 and 3.98a3 fixed executables are now at Rarewares.

oggenc2 batch file?

Reply #18
Thank you!

oggenc2 batch file?

Reply #19
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