Page 1 of 1
Convert directory of WAV Sounds to OGG Format
Posted: Wed Oct 17, 2007 5:24 pm
by Rings
Hi,
i have successfully written a programm which converts
automatically mp3's in a given directory to a standard 128kb format.
I used the lame-encoder commandline version for that.
But now, i have to convert some WAV Files (~ 20 gb )
into OGG-Files(To prevent space on hdisk).
Also i prefer a commandline version, which can be perfectly implemented
into my given source then.
any tips for me where to search ?
or should i use a dll for that ?
Posted: Wed Oct 17, 2007 5:26 pm
by Nik
I think ffmpg should be able to do that
Posted: Wed Oct 17, 2007 5:42 pm
by Thalius
mit
http://www.mpex.net/software/download/oggenc.html
is usable for that. To read out more mp3 if needed you can use mpg123 - theres a perl script for that which even sets ID3 tags.
See here:
ftp://ftp.faceprint.com/pub/software/scripts/mp32ogg
since you have wavs you should be ok with the oggenc.
Another Method ( if lazy ) use SUPER and let it work the queue down:
http://super.softonic.de/
Thalius
Posted: Wed Oct 17, 2007 5:45 pm
by Rings
that did it.
there is a encoder and decoder in it, so everything i need
thx guys.
Edit:
put the encoder.exe in the same path:
Code: Select all
Global FilesCount
Global filelame
Global SumOriginal.q
Global SumConverted.q
Global Path$
Global KB ;into which baudrate ?
Procedure.s ListFiles(directory.s , filename.s, extension.s , directoryid.l )
If Right(directory,1)<>""
directory+""
EndIf
If ExamineDirectory(directoryid,directory,"*.*")
dirid=NextDirectoryEntry(directoryid)
While dirid
dirtype = DirectoryEntryType(directoryid)
Select dirtype
Case #PB_DirectoryEntry_File
file.s=DirectoryEntryName(directoryid)
PrintN("File " + file.s)
this_extension.s=LCase(GetExtensionPart(file))
this_filename.s=LCase(Left(file,Len(file)-Len(this_extension)))
If Len(this_extension): this_filename=Left(this_filename,Len(this_filename)-1):EndIf
PrintN(this_extension + "#"+extension +" # " +this_filename+"#"+filename)
If this_extension=extension Or extension="*"
If this_filename=filename Or filename="*"
file.s=directory+DirectoryEntryName(directoryid)
;file contains the full path and filename
;you must insert here what to do with the file
FilesCount + 1
EnableGraphicalConsole(1)
ClearConsole()
PrintN("WAV2OGG - kb converter (c) by S.Rings 2007 ")
PrintN("----------------------------------------")
ConsoleLocate(0, 4)
EnableGraphicalConsole(0)
PrintN("- Working Directoy:")
PrintN(GetPathPart(file ))
PrintN("- scanning file :")
PrintN(GetFilePart(file ))
;dummy.s=Input()
;
;OpenFile(1,Path$+"log.txt")
PrintN("")
PrintN(">>> file will be converted,stay tuned ...")
PrintN(GetExtensionPart(File))
LameCommand.s=""
If kb<>128 And kb<>0
LameCommand.s=" -b "+Str(kb)
EndIf
c.s=Chr(34) + File + Chr(34) + Lamecommand
Ergebnis = RunProgram("oggenc.exe",c, "", #PB_Program_Wait + #PB_Program_Connect)
newFilename.s=Left(File,Len(file)-Len(GetExtensionPart(File)))+"ogg"
If FileSize(NewFilename ) > 0
PrintN("done. saved "+ Str(FileSize(File) - FileSize(NewFilename) ) )
filelame+1
DeleteFile(File)
;RenameFile(File+".mp3",File)
Else
PrintN("error converting")
EndIf
EndIf
EndIf
Case #PB_DirectoryEntry_Directory
If DirectoryEntryName(directoryid)<>"." And DirectoryEntryName(directoryid)<>".."
ListFiles(directory+DirectoryEntryName(directoryid)+"",filename,extension,directoryid+1)
EndIf
EndSelect
dirid=NextDirectoryEntry(directoryid)
Wend
EndIf
ProcedureReturn ""
EndProcedure
OpenConsole()
EnableGraphicalConsole(1)
ClearConsole()
EnableGraphicalConsole(0)
PrintN("WAV2OGG - kb converter (c) by S.Rings 2007 ")
PrintN("----------------------------------------")
Path$= LCase(ProgramParameter(0))
If Left(Path$,5)="/list"
Listmodus=0
PrintN("Listmodus active....")
Path$=ProgramParameter(1)
Else
Listmodus=1
EndIf
If Left(Path$,4)="/kb="
kb=Val(Right(Path$,Len(path$)-4))
Path$=ProgramParameter(1)
Else
KB=128
EndIf
If Path$ = ""
PrintN("Usage: ")
PrintN(" Convert_WAV2OGG_kb.exe [/kb=Bitrate] [Path] Converts Path to new OGG with Bitrates(Default is 128)")
PrintN("")
InitialPath$ = GetPathPart(ProgramFilename())
Path$ = PathRequester("Choose a path to convert", InitialPath$)
EndIf
t1=GetTickCount_()
listFiles(Path$,"*","wav",0)
t2=GetTickCount_()
PrintN("----------------------------------------")
PrintN(Str((t2-t1)/1000) + " seconds For "+Str(Filescount)+" files, "+Str(filelame)+" recodet")
PrintN("another fast hack done in Purebasic...:)")
PrintN("all done for "+path$)
;dummy.s=Input()
CloseConsole()
Posted: Sun Oct 21, 2007 11:11 am
by KarLKoX
You can find
here something i ve done, the code is very old, unoptimised, bad but should show how to encoder to/from wav/raw/mp3/ogg directly from the dll. (lame_enc and vorbis.dll)
Posted: Sun Oct 21, 2007 4:44 pm
by Edwin Knoppert
Lossless compresions using different codecs come close in filelength.
It's pretty hard to compress this data.
Afaik flac is ~ the smallest but then flac is not so handy for playing.
You may want to give wma lossless a try.
Check out dBpowerAMP Music Converter
Afaik it allows multiselect through Windows Explort > Convert to
Posted: Mon Oct 22, 2007 11:02 am
by inc.
Heres also an approach incl. a 2pass audio-normalizer and finally serving to ffmpeg.exe (comes with support of almost all useful codecs/formats).