HydrogenAudio

Lossy Audio Compression => AAC => AAC - General => Topic started by: spirit303 on 2003-06-30 01:26:58

Title: WAV-->AAC with Quicktime (WIN)
Post by: spirit303 on 2003-06-30 01:26:58
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
Title: WAV-->AAC with Quicktime (WIN)
Post by: rjamorim on 2003-06-30 01:44:41
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.
Title: WAV-->AAC with Quicktime (WIN)
Post by: FrDakota on 2003-07-03 12:19:16
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.
Title: WAV-->AAC with Quicktime (WIN)
Post by: richard123 on 2003-07-03 13:17:44
It would be easier to comment on your script if you posted it.
Title: WAV-->AAC with Quicktime (WIN)
Post by: FrDakota on 2003-07-03 13:51:02
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
Title: WAV-->AAC with Quicktime (WIN)
Post by: richard123 on 2003-07-03 15:22:36
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?
Title: WAV-->AAC with Quicktime (WIN)
Post by: Tomb on 2003-07-03 15:35:19
>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).
Title: WAV-->AAC with Quicktime (WIN)
Post by: FrDakota on 2003-07-03 15:43:24
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.
Title: WAV-->AAC with Quicktime (WIN)
Post by: richard123 on 2003-07-03 16:00:33
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?
Title: WAV-->AAC with Quicktime (WIN)
Post by: FrDakota on 2003-07-03 16:33:08
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 
Title: WAV-->AAC with Quicktime (WIN)
Post by: richard123 on 2003-07-03 18:02:31
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
Title: WAV-->AAC with Quicktime (WIN)
Post by: FrDakota on 2003-07-03 18:34:03
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
Title: WAV-->AAC with Quicktime (WIN)
Post by: richard123 on 2003-07-03 19:23:08
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.
Title: WAV-->AAC with Quicktime (WIN)
Post by: FrDakota on 2003-07-04 08:00:57
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.
Title: WAV-->AAC with Quicktime (WIN)
Post by: SentientPC on 2003-07-04 08:45:57
Great work FrDakota and richard123...looking forward to a "final" agreed revision 
Title: WAV-->AAC with Quicktime (WIN)
Post by: richard123 on 2003-07-04 09:22:51
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.
Title: WAV-->AAC with Quicktime (WIN)
Post by: SentientPC on 2003-07-04 09:42:54
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...
Title: WAV-->AAC with Quicktime (WIN)
Post by: FrDakota on 2003-07-04 15:57:40
(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.
Title: WAV-->AAC with Quicktime (WIN)
Post by: richard123 on 2003-07-04 16:38:00
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.
Title: WAV-->AAC with Quicktime (WIN)
Post by: c123 on 2003-07-04 21:45:50
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.
Title: WAV-->AAC with Quicktime (WIN)
Post by: FrDakota on 2003-07-05 01:01:03
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.
Title: WAV-->AAC with Quicktime (WIN)
Post by: spoon on 2003-07-05 09:34:24
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!
Title: WAV-->AAC with Quicktime (WIN)
Post by: c123 on 2003-07-05 10:47:24
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!
Title: WAV-->AAC with Quicktime (WIN)
Post by: c123 on 2003-07-05 11:03:13
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!
Title: WAV-->AAC with Quicktime (WIN)
Post by: c123 on 2003-07-05 12:00:56
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)
Title: WAV-->AAC with Quicktime (WIN)
Post by: FrDakota on 2003-07-05 12:56:16
Quote
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)

That's logical because of the way VBScript handles filnames with spaces.

I finaly got it right.

In the original CallQuickTime  function replace this :
Code: [Select]
  WshShell.Run("C:\Progra~1\QuickTime\QuickTimePlayer.exe " & Path)

 WScript.Sleep 3000

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


With this :
Code: [Select]
   Str = ""
  For c = 1 To Len(Path) 'Convert 1 \ in 2 \
    If Mid(Path, c, 1) = "\" Then
        Str = Str & "\\"
      Else
        Str = Str & Mid(Path, c, 1)
    End If
  Next

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

  Path = Chr(34) & Str & Chr(34)

  QT = Chr(34) & "C:\\Program Files\\QuickTime\\QuickTimePlayer.exe " & Chr (34)
 
  WshShell.Run(QT & Path)
 
  WScript.Sleep 3000


Now it works with filnames with spaces in them. Wherever you ask EAC to save wavs.

It's normal those strange named files, it's EAC that renames them temporarily until the encoding is finished. Delete them if it didn't work.

Also if the script goes wrong, it continues and may feed EAC with commands, so you get that cancel request.

A better way to stop script is to replace wscript.exe by cscript.exe in the EAC external compressor settings.

Then you'll be able to close the Command window thus ending the script.

If not you'll have to 'kill' wscript.exe in the task manager.  Be fast 

Good luck (Twice) 

PS : Try to increase the time given before the script returns to EAC after closing QuickTime. That will help EAC renaming correctly a file that could be locked by QuickTime while not completely exited.
Title: WAV-->AAC with Quicktime (WIN)
Post by: c123 on 2003-07-05 19:18:09
I doubled the times in the vbs file, and now I can encode four files without any errors  I also get to listen to a few seconds of each track after it gets encoded as a bonus

Only problem now - the files are not renamed at the end of the process, i.e. my four aac files are called "0tmp0(842.mp4", "0tmp(207!.mp4", "0tmp557)4.mp4", "0tmp)!3--.mp4".

Any suggestions?  (apart from listening to the files and manually naming them).
Title: WAV-->AAC with Quicktime (WIN)
Post by: FrDakota on 2003-07-05 21:18:51
Quote
Only problem now - the files are not renamed at the end of the process, i.e. my four aac files are called "0tmp0(842.mp4", "0tmp(207!.mp4", "0tmp557)4.mp4", "0tmp)!3--.mp4".

Any suggestions?  (apart from listening to the files and manually naming them).

That's what I explained above  QuickTime must have enough time to quit completely before returning the hand to EAC.

You must increase the delay at the end of the CallQuickTime function.

There :
Code: [Select]
  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.
'And EAC could not name the mp4 to what it should be
End Function


Because when QuickTime is not completely exited it locks the mp4 files and thus prevents EAC to name them properly.

Good luck (Thrice)   

Besides that, I think the limit in filename for QuickTime is 64 like in MacOS. Even under Windows, since Apple ported parts of MacOS for the QuickTime APIs if I remember well.
Title: WAV-->AAC with Quicktime (WIN)
Post by: FrDakota on 2003-07-06 07:39:31
To simplify things, here his the full corrected script for encoding thru EAC.

Code: [Select]
Function CallQuickTime(Path)
  Dim fso, mp4, mp5, c, Car, QT, Str
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set WshShell = WScript.CreateObject("WScript.Shell")

  Str = ""
  For c = 1 To Len(Path) 'Convert 1 \ in 2 \
    If Mid(Path, c, 1) = "\" Then
        Str = Str & "\\"
      Else
        Str = Str & Mid(Path, c, 1)
    End If
  Next

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

  Path = Chr(34) & Str & Chr(34)

  QT = Chr(34) & "C:\\Program Files\\QuickTime\\QuickTimePlayer.exe " & Chr (34)
 
  WshShell.Run(QT & Path)
 
  WScript.Sleep 3000

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
   'IMPORTANT : Increase the value under slower systems (.wav already exists bug)
  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 2000 'A little wait to let QuickTime exit before returning to EAC
  ' If not EAC could not be able to rename the wav file to original, then delete it.
  'IMPORTANT : Increase the value under slower systems (files do not regain their original names bug)
End Function


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

Dim wav

Set objArgs = WScript.Arguments

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


I hope it helps 
Title: WAV-->AAC with Quicktime (WIN)
Post by: jsnx on 2003-07-06 16:16:14
Thanks for sharing the script.  Works good.

There was one small glitch I encountered with WinAmp/IN_MP4 after following the setup instructions and using the script.

WinAmp would not play the file and gave this error message:
Gain control not yet implemented

The solution:
- Start EAC
- Click EAC --> Compression Options
- Click the External Compression tab
- Uncheck "Add ID3 tag"

The need to uncheck this is probably obvious to experienced users, but not to a newbie like me.
Title: WAV-->AAC with Quicktime (WIN)
Post by: SentientPC on 2003-07-08 03:26:09
Error: see below.
Title: WAV-->AAC with Quicktime (WIN)
Post by: SentientPC on 2003-07-08 03:33:50
Quote
To simplify things, here his the full corrected script for encoding thru EAC.

I hope it helps 

For some reason, when EAC spawns Quicktime, Quicktime loses focus immediately.  This causes me to get the "Do you really want to cancel extraction?" dialog in EAC, as it seems focus immediately is returning to EAC after spawning QT (and of course the script still is still running with EAC's dialog as its target).  If I click "No" and click on QT to give it focus, it continues on when the loop wait time is over, I suspect.

I have set all settings as stated by FrDakota previously in this thread.  I have made sure "On extraction, start external compressors queued in the background" is unchecked.  I have doubled all times to eliminate that potential reason.

Not sure what it is...
Title: WAV-->AAC with Quicktime (WIN)
Post by: FrDakota on 2003-07-08 07:34:39
Quote
I have set all settings as stated by FrDakota previously in this thread.  I have made sure "On extraction, start external compressors queued in the background" is unchecked.  I have doubled all times to eliminate that potential reason.

Not sure what it is...

This is strange, that's exactly what happened when I had the "On extraction, start external compressors queued in the background" checked.

When quicktime is launched does the Status window of EAC stop at "Compress Track By External Program", or do you see it continue ripping?

If it does there waybe something wrong with your EAC.

If not, I don't have a clue to the problem.

Maybe a solution would be to add a delay before QuickTime is launched.
Title: WAV-->AAC with Quicktime (WIN)
Post by: perplx on 2003-07-08 19:30:01
Im working on my own front end that uses winapi instead of send keys so losing focus shouldnt matter, that should solve your problem, should be done soon.
Title: WAV-->AAC with Quicktime (WIN)
Post by: spoon on 2003-07-08 23:20:21
SendMessages? I found the menu handling to be quite odd in QuickTime (I had to expand the menu first before sending a WM_COMMAND).
Title: WAV-->AAC with Quicktime (WIN)
Post by: perplx on 2003-07-09 01:03:48
I had to do that too, I wanted add bit rate ect to my front end, but I couldn't bring up the MPEG-4 Setting with freezing my program. I tried to set the bitrate using writeprocess memory but that led nowhere.  Oh well. I might finish today it, but im pretty lazy.
Title: WAV-->AAC with Quicktime (WIN)
Post by: zeer on 2003-07-09 15:28:27
this script version works for me with EAC
(if you don't touch the keyboard/mouse while ripping&encoding)

Code: [Select]
Function CallQuickTime(Path)
 Dim fso, mp4, mp5, c, Car, QT, Str, wav, wavx
 Set fso = CreateObject("Scripting.FileSystemObject")
 Set WshShell = WScript.CreateObject("WScript.Shell")
 Str = ""
 For c = 1 To Len(Path)
   If Mid(Path, c, 1) = "\" Then
       Str = Str & "\\"
     Else
       Str = Str & Mid(Path, c, 1)
   End If
 Next

' get filename.wav
 For c = 1 to Len(Path)
   If Mid(Path, c, 1) = "\" Then
       wavx=c
     Else
   End If
 Next

 wav=Right(Path,Len(Path)-wavx)
 wav=Left(wav,Len(Path)-3)

 mp4 = Left(Path, Len(Path)-3) & "mp4"
 Path = Chr(34) & Str & Chr(34)
 QT = Chr(34) & "C:\\Program Files\\QuickTime\\QuickTimePlayer.exe " & Chr (34)

 WshShell.Run(QT & Path)
 WScript.Sleep 3000
 WshShell.AppActivate(wav)
 WScript.Sleep(100)
 WshShell.AppActivate(wav)
 WshShell.AppActivate(wav)
 WshShell.SendKeys "^E"
 WScript.Sleep 500
 WshShell.SendKeys ("C:\Temp.mp4")
 WScript.Sleep 500
 WshShell.SendKeys "{ENTER}"
 WScript.Sleep 9999

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

 Do
 Loop Until fso.FileExists("C:\Temp.mp4")

 WScript.Sleep 2000
 WshShell.SendKeys "^W"
 WScript.Sleep 500

 fso.MoveFile "C:\Temp.mp4" , mp4
 Set fso = Nothing
 WScript.Sleep 1000
End Function

Dim wav
Set objArgs = WScript.Arguments
 wav = objArgs(0)
 mp4 = objArgs(1)
CallQuickTime(wav)
WshShell.Run("taskkill /f /im CScript.exe")
Wscript.Quit


p.s. the only thing i need now is Case's tag with apple's MP4 tagging code from menno...
Title: WAV-->AAC with Quicktime (WIN)
Post by: rpop on 2003-07-10 23:36:08
I haven't tried using this script, but I've had lots of problems with windows losing focus in the past if X-Mouse is activated, especially if Autoraise when activating is enabled too.
Title: WAV-->AAC with Quicktime (WIN)
Post by: Nic on 2003-07-11 00:05:50
As soon as QuickTime 6 came out, I grabbed the SDK and tried to write an executable to take a Wav and make an AAC file. But does it work? Does it hell.

When I try to get the codec handler it just returns an error. Works fine for all there other codecs but not AAC. I don't know if they've just disabled it for windows or what.

Ill contact the QuickTime guys (I was at the WWDC thang in San Francisco and got to all the new stuff in QT 6.4 and its AAC improvements) and see if they can help me.

(if anyone wants the source let me know...)

-Nic
Title: WAV-->AAC with Quicktime (WIN)
Post by: perplx on 2003-07-11 06:33:05
A question for spoon or anyone else that knows. Whats the best way to open the export dialog for Quicktime? I currently use
Code: [Select]
  sendMessage(quicktime,WM_INITMENU,$f10c9,0);
 sendMessage(quicktime,WM_COMMAND,$E,0);

but the wparams seem to change evertime I restart.
Title: WAV-->AAC with Quicktime (WIN)
Post by: zeer on 2003-07-13 11:08:13
It seems to get Quicktime api/sdk to work the APP must be registered (ie you should pay Apple for license) in Apple's exe database.

SonicFoundry Vegas 4.0 + Batch Converter 5.0 can export in all these QT formats EXCEPT new QuickTime AAC - i think they will add this support in next patch or 2...
Title: WAV-->AAC with Quicktime (WIN)
Post by: FrDakota on 2003-07-14 09:42:55
Quote
Code: [Select]
 While fso.FileExists ("C:\Temp.mp5")
  WScript.Sleep 1000
 Wend

 Do
 Loop Until fso.FileExists("C:\Temp.mp4")

Zeer!

I've just noticed that your modification of the script cannot work correctly, especially if an encoding fails.

You wait until the mp5 dissapears. But if the encoding fails the mp4 will never be created.

So your script will loop indefinitely on waiting mp4 to exist.

That's why in my script, if the mp4 isn't created it loops to re-export it.

Doh! 
Title: WAV-->AAC with Quicktime (WIN)
Post by: Nic on 2003-07-14 09:47:27
@zeer:
Ahh, I guess that maybe the case. Its a shame because exactly the same code works fine on an Apple machine.

-Nic
Title: WAV-->AAC with Quicktime (WIN)
Post by: spoon on 2003-07-14 11:11:38
Quote
A question for spoon or anyone else that knows. Whats the best way to open the export dialog for Quicktime? I currently use
Code: [Select]
  sendMessage(quicktime,WM_INITMENU,$f10c9,0);
 sendMessage(quicktime,WM_COMMAND,$E,0);

but the wparams seem to change evertime I restart.

That is as far as I got, they seem to not want other programs to interface with it...

Is it possible to enum the menu items?
Title: WAV-->AAC with Quicktime (WIN)
Post by: zeer on 2003-07-14 14:07:56
2 FrDakota:

Nobody is perfect. Actually, the problem of not creating temp.mp4 does not appear while i ripped (~40 CDs).

It is assumed that temp.mp5 is enough ... and real test shows that it is.
although if i invent something more robust, i will let you know...
Title: WAV-->AAC with Quicktime (WIN)
Post by: zaphod on 2003-07-27 16:12:39
I've made a tiny Python script which "abuses" FrDakota's script for batch encoding outside of EAC. I'm a very inexperienced coder and the script could doubtlessly be much more elegant. Also, it doesn't provide any safety at all, it'll just fail without a useful error message if something is not right.

It expects eac.vbs in C:\, but that can easily be changed, as all the other absolute references. Thanks to FrDakota's script, encoding to AAC with QuickTime has become a real possibility and I hope my addition is of use for some...

Code: [Select]
# This should serve to use the eac.vbs script to batch encode files in a
# given directory (and its subdirectories) using QuickTime AAC.
# Many thanks to FrDakota for making this possible!
#
# Usage: python qtmp4.py c:\*.wav
# -> This will encode all wave files on drive C:
# -> The encoded files will be in the same directory as the source files,
#    and with the same name.

import sys
import os

print "Compiling list of wave files..."
os.system("dir " + sys.argv[1] + " /s /b > c:\\wavs.txt")
f=open("c:\\wavs.txt", "r")
name=f.readline()

while name!="" :

    wav=name[:-5] + ".wav"
    mp4=name[:-5] + ".mp4"

    print "Encoding " + wav + "..."
    os.system("cscript //Nologo //H:CScript c:\\eac.vbs " + "\"" + wav + "\" " + "\"" + mp4 + "\"")

#    os.remove(wav)             # un-comment if you want to have the wave file deleted after encoding

    name=f.readline()

print "Done!"
sys.exit()


Cheers, Zaphod