Convert directory of WAV Sounds to OGG Format

Share your advanced PureBasic knowledge/code with the community.
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Convert directory of WAV Sounds to OGG Format

Post 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 ?
Last edited by Rings on Wed Oct 17, 2007 8:32 pm, edited 2 times in total.
SPAMINATOR NR.1
Nik
Addict
Addict
Posts: 1017
Joined: Fri May 13, 2005 11:45 pm
Location: Germany
Contact:

Post by Nik »

I think ffmpg should be able to do that
Thalius
Enthusiast
Enthusiast
Posts: 711
Joined: Thu Jul 17, 2003 4:15 pm
Contact:

Post 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
"In 3D there is never enough Time to do Things right,
but there's always enough Time to make them *look* right."
"psssst! i steal signatures... don't tell anyone! ;)"
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post 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()
SPAMINATOR NR.1
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post 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)
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post 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
inc.
Enthusiast
Enthusiast
Posts: 406
Joined: Thu May 06, 2004 4:28 pm
Location: Cologne/GER

Post 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).
Check out OOP support for PB here!
Post Reply