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: WAV-->AAC with Quicktime (WIN) (Read 27508 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

WAV-->AAC with Quicktime (WIN)

i need help

how do i convert my 500 WAV files into AAC (mp4) with the best quality encoder apple quick time 6.3 for !windows!  ?
i don' wanna open each file and export it. it will keep me goin for years !!!

please tell me how to do it

thank u guys

WAV-->AAC with Quicktime (WIN)

Reply #1
You'll have to wait. At the time, there's no practical solution for batch encoding with QuickTime.

Worst case, Apple is supposed to release iTunes for Windows by the end of this year. Then you'll be able to do batch encoding.

No immediate solution, sorry.

WAV-->AAC with Quicktime (WIN)

Reply #2
I have quite successfully done a VBScript that controls (well it's more manipulates) QuickTime to encode wav files in a directory to mp4.

It works quite well. But I'm facing two big problems.

1 - The way QuickTimes reacts when used through scripts.
.    I load a file, export it. (And the Export bar is increasing), the mp4 file is created alongside the wav one.
.    The At the end QuickTimes says " Cannot Export xxxx.WAV cause it already exists" ?????????
.    I never asked it to Export the Wav.... But that problem seems to be related to the speed at wich I'm sending orders to QuickTime.

2 - Some foreign characters are removed when I send the path to the file. "ô" for example, but they exist in the string.
.    i.e : The file named "10 - Axelle Red - Quitter Tôt.wav" is sent "10 - Axelle Red - Quitter Tt.wav"
.    Some handling to do there.

There is housekeeping to do also.

Also don't expect a blazing speed encoding.

WAV-->AAC with Quicktime (WIN)

Reply #3
It would be easier to comment on your script if you posted it.

WAV-->AAC with Quicktime (WIN)

Reply #4
Ok I post it.

Things to know. I made a direct reference to a folder "C:\Test" in the script. That's where I put the wav files.

If an mp4 encoding misses, the script must be stopped (killing wscript in the task manager, or closing the script windows for cscript), the mp4 files must be deleted before relaunching the encoding (not checked for mp4 presence).

I created an empty.mov file in the QuickTime folder (file-new then save), and load it to avoid QT to load web ad.

I used paths with only one "\", but VBScrit would preferer "\\" at some occasions. I'll have to do it later, store the paths to files both ways. One for internal file handling of VBScript (like for mp5) and one addressed to file inserts in QuickTime, because of course QuickTime won't accept paths with "\\".

For foreign accents, maybe I'll have to send the chars 1 by 1, or maybe I use the bad command.

I'm very new to VBScript. So don't flame me  I only tested it with 4 files successive encoding.

Copy the text below and save it in a new text file. Then rename to something like this "encode.vbs"

PS : I forgot to tell that the mp4 encoding will be done with the last settings used in QuickTime.

Also, do NOT do anything when using the script and quit any application that could steal QuickTime's focus. QuickTime is and must stay the frontmost application.

Code: [Select]
'Batch QuickTime by frdakota@hotmail.com

Function ShowFolderList(folderspec)
  Dim fso, f, f1, fc, s
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set f = fso.GetFolder(folderspec)
  Set fc = f.Files
  fileCount = 0
  For Each f1 In fc
     s = s & f1.name
     s = s &  chr(13)
     files(fileCount) = Path & "\" & f1.name
     fileCount = fileCount + 1
  Next
  ShowFolderList = s
End Function


Function WavList(Count)
  Dim i, w
  w = 0
  For i = 0 To Count -1
     If LCase(Right(files(i), 3)) = "wav" Then
       Wav(w) = files(i)
       w = w + 1
     End If
  Next
  WavList = w
End Function

Function CallQuickTime(Path)
  Dim fso, mp5
  Set fso = CreateObject("Scripting.FileSystemObject")
  WScript.Sleep 5000
  WshShell.SendKeys "%FO"
  WScript.Sleep 1000
  WshShell.SendKeys "%D"
  WshShell.SendKeys Path
  WScript.Sleep 1000
  WshShell.SendKeys "{ENTER}"
  WScript.Sleep 1000
  WshShell.SendKeys "%FE"
  WScript.Sleep 1000
  WshShell.SendKeys "%E"
 

  mp5 = Left(Path, Len(Path)-3) & "mp5"

  WScript.Sleep 9000

  While fso.FileExists(mp5)
  Wend
 
'The Enter was added in case QuickTime says .wav file already exists, to clear the error.
'I launches playing if all goes well.
  WshShell.SendKeys "{ENTER}"
 
End Function

Dim files(255), fileCount, List, Wav(255), wavCount, Path, ReturnCode

Path = "C:\Test"
List = ShowFolderList( Path )

wavCount = WavList(fileCount)

If wavCount > 0 Then
  Set WshShell = WScript.CreateObject("WScript.Shell")

' One \ so I use ~1
  WshShell.Run("C:\Progra~1\QuickTime\empty.mov")

' Could be coded "C:\\Program Files\\QuickTime\\empty.mov"
  ReturnCode = WshShell.Run("C:\Progra~1\QuickTime\empty.mov", 1, True)
  WScript.Sleep 5000
  WshShell.AppActivate ("empty.mov")
  WScript.Sleep 2000
 
  For i = 0 To wavCount -1
    CallQuickTime(wav(i))
  Next
 
 
Else
  Wscript.Echo("No wav files found.")
End If

Wscript.Quit

WAV-->AAC with Quicktime (WIN)

Reply #5
Perhaps we are using different versions of QT.  I'm using QT Pro 6.3.

With that version, in the main program I can just launch QT, rather than go through the empty.mov sequence

In the callQT function, the following sequence of keystrokes works for me:
%FO
Path
ENTER
ESC
%FE
ENTER

otherwise, seems to work fine on extremely limited testing (and no testing on odd characters)

Very nice job.  I assume you have other programming experience?

WAV-->AAC with Quicktime (WIN)

Reply #6
>how do i convert my 500 WAV files into AAC (mp4) with the best quality encoder apple quick time 6.3 for !windows! ?<

Spoon (dbpoweramp Music Converter) is working on a Codec for use with Quick Time. I presume we will then be able to convert or rip direct to AAC (MP4) as we can with all the other codecs using his excellent application (which it supports).

WAV-->AAC with Quicktime (WIN)

Reply #7
It strange to send an ESC to QT it should clear a menu that is already cleared.

I'm using QT Pro 6.3 too (English)

I could even launch an encoding through EAC and CDex, EAC should be set to wait the encoding finishes before moving to next track. If not EAC steals the focus of QT. And EAC is a real stealer of focus in any case.

The strange problem is that with EAC with the same script I get the .wav already exist for QT Export, but not with CDex ??????

But to use properly that sort of script I think I should add a CloseQuickTime part to be able to regain focus later.

Well. I used to progam in BASIC, Turbo Pascal and assembler on various systems. But I did lose the habit of programing for some time now. It's hard for me to catch up with the "Visual" things.

WAV-->AAC with Quicktime (WIN)

Reply #8
I send an escape because sometimes the Edit menu gets the focus, and %fe for some reason activiates the Edit menu rather than Export.

I haven't gotten the "wav already exists" using your script with my edits, but I'll test more tonight and report back.  I've been ripping a CD with EAC, then converting the lot to mp4.

Closing QT and then re-starting should work to keep focus.  Shouln't AppActivate grab focus?

I'll confess to not having much experience with vbs either, but I've played with enough other languages over the years that it's usually easy to pick up new stuff. vbs seems very similar to the visual basic included with Excel, etc.  Is there a good online list of commands?

WAV-->AAC with Quicktime (WIN)

Reply #9
My problem is that I couldn't find a reference manual of VBScript in DOC or PDF for example. I had to browse many sites to find valuable information on precise topics.

I don't like the idea to go to MS' site to find infos about it. I prefer to have like a journal or book.

The problem wiht AppActivate is that you have to know the name of the last loaded file to use it (hence the name of the window) or maybe I missed something.

I'm using a XP 1600+ on with Windows XP. And I continue to get that infamous ".wav file already exists" but not all the time and not always on the same file 

WAV-->AAC with Quicktime (WIN)

Reply #10
You appear to be right about AppActivate.  I'm thinking of invoking and then exiting QT within the callQt routine.  Here's my current revision, btw:

Code: [Select]
'Batch QuickTime by frdakota@hotmail.com
' updated by richard 3 July 2003

Function WavList(Path)
 Dim fso, f, f1, fc
 Dim i, w

 Set fso = CreateObject("Scripting.FileSystemObject")
 Set f = fso.GetFolder(Path)
 Set fc = f.Files

 w = 0
 For Each f1 In fc
    If LCase(Right(f1.name, 3)) = "wav" Then
      Wav(w) = Path & "\" & f1.name
      w = w + 1
    End If
 Next

 set fso = nothing
 WavList = w
End Function

Function CallQuickTime(Path)
 Dim fso, mp5

 ' find a way of grabbing focus

 WScript.Sleep 5000
 WshShell.SendKeys "%FO"
 WScript.Sleep 1000
 WshShell.SendKeys Path
 WScript.Sleep 1000
 WshShell.SendKeys "{ENTER}"
 WScript.Sleep 1000
 WshShell.SendKeys "{ESC}"
 WScript.Sleep 1000
 WshShell.SendKeys "%FE"
 WScript.Sleep 1000
 WshShell.SendKeys "{ENTER}"
 
 mp5 = Left(Path, Len(Path)-3) & "mp5"

 WScript.Sleep 9000

 Set fso = CreateObject("Scripting.FileSystemObject")
 While fso.FileExists(mp5)
 Wend

 set fso = nothing

End Function

Dim fileCount, List, Wav(255), wavCount

Path = "D:\cds\mA"
wavCount = WavList(Path)

If wavCount > 0 Then
 Set WshShell = WScript.CreateObject("WScript.Shell")

 WshShell.Run("D:\Progra~1\QuickTime\QuickTimePlayer.exe")
 WScript.Sleep 5000
 
 For i = 0 To wavCount -1
   CallQuickTime(wav(i))
 Next
 
 WshShell.SendKeys "%FX"
 Wscript.Echo("Done")
 
Else
 Wscript.Echo("No wav files found.")
End If

Wscript.Quit

WAV-->AAC with Quicktime (WIN)

Reply #11
I saw you cleaned the unused variables    They were from a script I got somewhere.

Is it necessary to do that ? Set fso = nothing

I arrived to send some specially accented caracters to QT. But some like " É " ( Acute E) will cause problems.

I saw on MS' site that they use pauses between sendkeys, so it seems to be important.

Here is the modified CallQuickTime function.

Code: [Select]
Function CallQuickTime(Path)
  Dim fso, mp5, c, Car, mp4
  Set fso = CreateObject("Scripting.FileSystemObject")
  WScript.Sleep 5000
  WshShell.SendKeys "%FO"
  WScript.Sleep 1000
  WshShell.SendKeys "%D"
 
 
  For c = 1 To Len(Path)
     Car = Mid(Path, c, 1)
     Select Case Car
       Case "â"
         Car = "{^}a"
       Case "ê"
         Car = "{^}e"
       Case "î"
         Car = "{^}i"
       Case "ô"
         Car = "{^}o"
       Case "û"
         Car = "{^}u"
       Case "Â"
         Car = "{^}A"
       Case "Ê"
         Car = "{^}E"
       Case "Î"
         Car = "{^}I"
       Case "Ô"
         Car = "{^}O"
       Case "Û"
         Car = "{^}U"
       Case "ä"
         Car = "{¨}a"
       Case "ë"
         Car = "{¨}e"
       Case "ï"
         Car = "{¨}i"
       Case "ö"
         Car = "{¨}o"
       Case "ü"
         Car = "{¨}u"
       Case "Ä"
         Car = "{¨}A"
       Case "Ë"
         Car = "{¨}E"
       Case "Ï"
         Car = "{¨}I"
       Case "Ö"
         Car = "{¨}O"
       Case "Ü"
         Car = "{¨}U"
     End Select
     
     WshShell.SendKeys (Car)
  Next
     
  WScript.Sleep 1500
  WshShell.SendKeys "{ENTER}"

Do 'Loop until the mp4 file really exists
  WScript.Sleep 1500
  WshShell.SendKeys "%FE"
  WScript.Sleep 2000
  WshShell.SendKeys "{ENTER}"
 

  mp5 = Left(Path, Len(Path)-3) & "mp5"
  mp4 = Left(Path, Len(Path)-3) & "mp4"
  WScript.Sleep 9000

'Check to see if the temp file is still here
  While fso.FileExists(mp5)
  Wend
 
'The Enter was added in case QuickTime says .wav file already exists, to clear the error.
'It launches playing if all goes well.
  WshShell.SendKeys "{ENTER}"
  WScript.Sleep 500
  WshShell.SendKeys "{ESC}"
  WScript.Sleep 500

Loop Until fso.FileExists(mp4)
  Set fso = Nothing
End Function

WAV-->AAC with Quicktime (WIN)

Reply #12
A number of web sites recommend set fso = nothing.  Probably does not matter.

Consider this to invoke QT and make sure we have focus

Code: [Select]
  WshShell.Run("D:\Progra~1\QuickTime\QuickTimePlayer.exe " & Path)
 WScript.Sleep 5000
 begin = left(Path, 10)
 WshShell.AppActivate begin


edit: I'm also getting the wav already exists error.

WAV-->AAC with Quicktime (WIN)

Reply #13
Quote
Perhaps we are using different versions of QT.  I'm using QT Pro 6.3.

With that version, in the main program I can just launch QT, rather than go through the empty.mov sequence

In the callQT function, the following sequence of keystrokes works for me:
%FO
Path
ENTER
ESC
%FE
ENTER

otherwise, seems to work fine on extremely limited testing (and no testing on odd characters)

I found out why it wasn't working for you...

It's not because of QuickTime, it was the OS. Mine is french.

So WshShell.SendKeys "%D" was to set the cursor in the file destination field (well it's ludicrous in fact, not needed), but corresponding to the french underlined letter when I press Alt.

WshShell.SendKeys "%E" also was used for the E of "Enregistrer" so your way to put "Enter" is the most localisation independent one.

I'm correcting the script accordingly

I also modified the script to loop on failed encodings.
If the mp4 file does not exist when the mp5 one dissapears, then it exports again.

One thing that is great with QuickTime is that it can do batch transcoding this way too.

Since QuickTime can open mp3 files you only have to export to mp4 to convert.

So another script where "wav" is replaced with "mp3" will do just that fine.

I'm updating the CallQuickTime function above.

WAV-->AAC with Quicktime (WIN)

Reply #14
Great work FrDakota and richard123...looking forward to a "final" agreed revision 

WAV-->AAC with Quicktime (WIN)

Reply #15
Another point I noticed - QT won't open a file if the name is too long.    I'm not sure what the maximum length is, but I'm renaming anything with a filename longer than 60 chars to a temp name, then renaming back after conversion.

I wish I had a better way to make sure QT had focus or to feed chars to it when it doesn't have focus.

WAV-->AAC with Quicktime (WIN)

Reply #16
Quote
I'm not sure what the maximum length is, but I'm renaming anything with a filename longer than 60 chars to a temp name, then renaming back after conversion.

Longer than and including 60, right?  Looks like the maximum allowable length for import is 59 chars <excluding the .WAV extension of course> (correct me if I'm wrong on that).

Good stuff...

 

WAV-->AAC with Quicktime (WIN)

Reply #17
(w00t)  I finaly found how the infamous ".wav file already exists" problem happens, but not why.

This was the problem :
Code: [Select]
   While fso.FileExists ("C:\Temp.mp5")
  Wend


Apparently that perturbs QuickTime I don't understand why, and it seems a valid code.

Now this works :
Code: [Select]
   While fso.FileExists ("C:\Temp.mp5")
    WScript.Sleep 1000
  Wend


Adding the delay in the loop fixed the problem. 

And so I could with success interface the script with EAC.

It is important to set EAC as I did.

EAC Options -> Tools (TAB) uncheck "On extraction, start external compressors queued in the background"

EAC -> Compression options -> External compression (TAB)
Check "Use external program for compression" 
Set the "User defined encoder"
Extension ".mp4"
The program is "C:\Windows\SYSTEM32\wscript.exe"
And "Additional command line options" is set to "C:\SAVE\EAC.vbs %s %d"

"C:\SAVE\EAC.vbs" is the "full" path to where I put my EAC.VBS script modify accordingly.

Here is the script of the EAC.vbs

Code: [Select]
Function CallQuickTime(Path)
  Dim fso
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set WshShell = WScript.CreateObject("WScript.Shell")
  WshShell.Run("C:\Progra~1\QuickTime\QuickTimePlayer.exe " & Path)

  WScript.Sleep 3000

  mp4 = Left(Path, Len(Path)-3) & "mp4"

Do 'Loop until the mp4 file really exists

  WScript.Sleep 1500
  WshShell.SendKeys "%FE" 'File Export, could be "^E"
  WScript.Sleep 500
  WshShell.SendKeys ("C:\Temp.mp4") 'Temporary mp4 filename
  WScript.Sleep 500
  WshShell.SendKeys "{ENTER}"
  WScript.Sleep 8000

'Check to see if the temp file is still here
  While fso.FileExists ("C:\Temp.mp5")
    WScript.Sleep 1000 'With CScript.exe instead of WScript.exe I could put 500
  Wend
 
'The Enter was added in case QuickTime says .wav file already exists, to clear the error.
'I launches playing if all goes well.
  WScript.Sleep 500
  WshShell.SendKeys "{ENTER}"
  WScript.Sleep 500
  WshShell.SendKeys "{ESC}"
  WScript.Sleep 500

Loop Until fso.FileExists("C:\Temp.mp4")
'Close QuickTime
  WScript.Sleep 500
  WshShell.SendKeys "{ESC}"
  WScript.Sleep 500
  WshShell.SendKeys "%FX"
  'Move the Temp.mp4 to the right place while renaming it
  fso.MoveFile "C:\Temp.mp4" , mp4
  Set fso = Nothing
  WScript.Sleep 1000 'A little wait to let QuickTime exit before returning to EAC
  ' If not EAC could well not be able to rename the wav file to original, then delete it.
End Function


'Get the 2 first arguments and assumes they are %s & %d (source and destination in EAC)

Dim wav, mp4

Set objArgs = WScript.Arguments

  wav = objArgs(0)
  mp4 = objArgs(1)
 
CallQuickTime(wav)
Wscript.Quit


BEWARE :
Renaming the temp file after the encoding regives the full name, as long as it is.

If a filename is too long QuickTime WILL complain about it.

Simply shorten it afterwards.

Now remains the Tag problem, well Spoon, that's up to you apparently   

Thanks Richard123 for your inputs. And this is not over.

WAV-->AAC with Quicktime (WIN)

Reply #18
I had added a delay to the loop

Code: [Select]
While fso.FileExists ("C:\Temp.mp5")
   WScript.Sleep 1000
 Wend


because file operations usually use up a lot of resources.  Adding the delay reduces the number of operating system calls.  I haven't seen any ".wav file already exists" since making the change, although didn't realize the connection.

Unattended operation makes life much easier.

WAV-->AAC with Quicktime (WIN)

Reply #19
Hi

When I tried to get this to work, I got a "Windows Script Host" error:
Script: D:\Save\EAC.vbs
Line: 5
Char: 1
Error: The system cannot find the file specified.
Code: 800700002
Source: (null)

My source wav is in D:\Test ; I tell EAC to save to D:\Save

I have changed the paths in the VBS to point to where they should...  What's going wrong?  Thanks for sharing this script in any case.

WAV-->AAC with Quicktime (WIN)

Reply #20
Well for the script to work QuickTime Pro must be installed.

And you'll have to verify that the path given in the script corresponds to the path where you installed QuickTime.

My QuickTime is in "C:\Program Files\QuickTime\QuickTimePlayer.exe" yours ?

I'm using FAT 32 so that's why the Progra~1 works, I don't know if it does under NTFS.

You could try this "C:\\Program Files\\QuickTime\\QuickTimePlayer.exe" as a replacement.

Another thing, the destination path of the mp4 is the same as the source wav.
changing that is possible but needs a string handling I've not written.

I don't advise you to change that since EAC must find the mp4 where the wav are since it needs to rename both after encoding.

And I only specified the two temp (mp4 and mp5) files to be at root to have a short path.

The wav files are placed where you selected in EAC and so that's where the final mp4 will be.

Good luck.

WAV-->AAC with Quicktime (WIN)

Reply #21
I should have something to release either today or tomorrow - using a method not to dissimilar to yours...Apple as far as I can tell are stopping 3rd party programs from using the Quicktime API from outputting mp4 audio, I can convert to any of the other formats or even to a mp4 movie, but always they disable the audio stream, perhaps because of licensing issues I don't know, all I know is it sucks!

WAV-->AAC with Quicktime (WIN)

Reply #22
Quote
Well for the script to work QuickTime Pro must be installed.

- Yep it's installed.

Quote
And you'll have to verify that the path given in the script corresponds to the path where you installed QuickTime.

- Yep that's OK.

Quote
My QuickTime is in "C:\Program Files\QuickTime\QuickTimePlayer.exe" yours ?

- "D:\Program Files\QuickTime\QuickTimePlayer.exe"

Quote
I'm using FAT 32 so that's why the Progra~1 works, I don't know if it does under NTFS.

- also using FAT32.  Tried truncating to "Progra~1", no change.

Quote
You could try this "C:\\Program Files\\QuickTime\\QuickTimePlayer.exe" as a replacement.

- tried, but no joy

Quote
Another thing, the destination path of the mp4 is the same as the source wav.
changing that is possible but needs a string handling I've not written.

- OK thanks, wasn't doing that before...  However, no change when I do that.

Quote
I don't advise you to change that since EAC must find the mp4 where the wav are since it needs to rename both after encoding.

- OK, source file is now d:\test.wav and target file is d:\

Quote
And I only specified the two temp (mp4 and mp5) files to be at root to have a short path.

- now my test source file is also at the root (and the vbs script is in D:\Save)

Quote
The wav files are placed where you selected in EAC and so that's where the final mp4 will be.

Good luck.

- cheers, unfortunately still get the same error...
***update*** just got to work.  will test with more than one file and post back shortly.

thanks for the help FrDakota!

WAV-->AAC with Quicktime (WIN)

Reply #23
Just tried to encode four wav files, and
ED:\Temp.mp4
encountered the infamous "file already exists" error  So I suppose I need to add richard123's delay.

Couple of other things - when I first launch the process, I get a message (from EAC I think) "Do you really want to stop compression ?" - do you as well?

Also, from my above test - I now have two mp4 files, but the names are a bit curious ("Temp.mp4" and "0tmp)!3--.mp4").  Is this because the process did not complete?  Also one of my wav files is no called 0tmp)!3--.wav (original name was 03. Venus As A Boy.wav).

So for me it's working, sort of, which is already a lot better than last night!

WAV-->AAC with Quicktime (WIN)

Reply #24
Keep on getting the "file exists already" error message.  In my test to encode four files, the best I've done is three out of four  All but one of the files have *strange* names e.g. 0tmp((957.mp4.  Often I'll have the same file encoded twice (?!).  And of course one of wav files no longer has the correct name.

I've tried increasing the time of WScript.Sleep from 1000 to 4000, e.g.

While fso.FileExists ("D:\Temp.mp5")
WScript.Sleep 4000 'With CScript.exe instead of WScript.exe I could put 500
Wend

but still I get the "file exists already".  Could this be because my system is slower than yours (mobile P3 1.13, 512 RAM, XP Pro with SP1) or is likely to be something else?

Cheers

p.s. on my system, the .vbs will only work if I give a truncated path to QT (i.e. D:\Progra~1\QuickTime\QuickTimePlayer.exe works but not D:\Program Files\QuickTime\QuickTimePlayer.exe)