User Tools

Site Tools


software:mov2flv

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Last revisionBoth sides next revision
software:mov2flv [2010/10/10 04:40] – created adminsoftware:mov2flv [2010/10/10 16:02] admin
Line 17: Line 17:
 -- It uses Adobe After Effects CS3 to convert, correct audio offset and render into flv with on6/mp3 codec -- It uses Adobe After Effects CS3 to convert, correct audio offset and render into flv with on6/mp3 codec
 -- --
 +--  THIS SCRIPT NEEDS SPECIAL PERMISSION FROM AFTER EFFECTS, OTHERWISE FILECOPY WILL NOT WORK. ENABLE:
 +--  Preferences > General, and select “Allow Scripts To Write Files And Access Network.”
  
 -- Applet Code -- Applet Code
Line 22: Line 24:
 -- The following appears only when the droplet is double clicked -- The following appears only when the droplet is double clicked
 on run on run
-    display dialog "ae_mov2flv.app" & return & return & "Convert a mov w/Audio to a flv file" & return & return & "To convert .mov files to .flv, just drag the files or folders of files onto this applet.  The script will start Adobe After Effects CS3, setup a composition, correct offset between audio video." & return & return & "The resulting converted .flv movie files will be in the same folder."+ display dialog "ae_mov2flv.app" & return & return & "Convert a mov w/Audio to a flv file" & return & return & "To convert .mov files to .flv, just drag the files or folders of files onto this applet.  The script will start Adobe After Effects CS3, setup a composition, correct offset between audio video." & return & return & "The resulting converted .flv movie files will be in the same folder."
 end run end run
  
 -- This droplet processes both files or folders of files dropped onto the applet -- This droplet processes both files or folders of files dropped onto the applet
 on open (these_items) on open (these_items)
-    repeat with i from 1 to the count of these_items + repeat with i from 1 to the count of these_items 
-        set this_item to (item i of these_items) + set this_item to (item i of these_items) 
-        set the item_info to info for this_item + set the item_info to info for this_item 
-        if folder of the item_info is true then + if folder of the item_info is true then 
-            process_folder(this_item) + process_folder(this_item) 
-        else if (alias of the item_info is false) and (the name extension of the item_info is "MOV") then + else if (alias of the item_info is false) and (the name extension of the item_info is "MOV") then 
-            process_item(this_item) + process_item(this_item) 
-        end if + end if 
-    end repeat + end repeat 
-     +  
-    --    display dialog "Converted the movie(s)." & return & return & "Enjoy!"+ -- display dialog "Converted the movie(s)." & return & return & "Enjoy!"
 end open end open
  
 -- this sub-routine processes folders -- this sub-routine processes folders
 on process_folder(this_folder) on process_folder(this_folder)
-    set these_items to list folder this_folder without invisibles + set these_items to list folder this_folder without invisibles 
-    repeat with i from 1 to the count of these_items + repeat with i from 1 to the count of these_items 
-        set this_item to alias ((this_folder as text) & (item i of these_items)) + set this_item to alias ((this_folder as text) & (item i of these_items)) 
-        set the item_info to info for this_item + set the item_info to info for this_item 
-        if folder of the item_info is true then + if folder of the item_info is true then 
-            process_folder(this_item) + process_folder(this_item) 
-        else if (alias of the item_info is false) and (the name extension of the item_info is "MOV") then + else if (alias of the item_info is false) and (the name extension of the item_info is "MOV") then 
-            process_item(this_item) + process_item(this_item) 
-        end if + end if 
-    end repeat+ end repeat
 end process_folder end process_folder
  
 -- this sub-routine processes files -- this sub-routine processes files
 on process_item(this_item) on process_item(this_item)
-    -- NOTE that the variable this_item is a file reference in alias format + -- NOTE that the variable this_item is a file reference in alias format 
-    set full_path to the POSIX path of this_item + set full_path to the POSIX path of this_item 
-    -- !!! MODIFY THESE PARAMETERS TO SUIT if you have other preferences you'd like to use + -- !!! MODIFY THESE PARAMETERS TO SUIT if you have other preferences you'd like to use 
-    -- activate AE (this will be ignored if it's already open) + -- activate AE (this will be ignored if it's already open) 
-    try + try 
-        tell application "Adobe After Effects CS3" + tell application "Adobe After Effects CS3" 
-            with timeout of 300 seconds + with timeout of 300 seconds 
-                activate + activate 
-                 +  
-                -- begin After Effects script: close any open project (if it isn't rendering) + -- begin After Effects script: close any open project (if it isn't rendering) 
-                set line1 to "if (app.project.renderQueue.rendering != true){" & return + set line1 to "if (app.project.renderQueue.rendering != true){" & return 
-                set line2 to "app.project.close(CloseOptions.DO_NOT_SAVE_CHANGES);}" & return + set line2 to "app.project.close(CloseOptions.DO_NOT_SAVE_CHANGES);}" & return 
-                set closeAnyExistingProjects to line1 & line2 + set closeAnyExistingProjects to line1 & line2 
-                DoScript closeAnyExistingProjects with override + DoScript closeAnyExistingProjects with override 
-                -- end After Effects script + -- end After Effects script 
-                 +  
-                -- begin After Effects script + -- begin After Effects script 
-                set line1 to "if(!app.project){" & return + set line1 to "if(!app.project){" & return 
-                set line2 to "var myProject = app.newProject();}" & return + set line2 to "var myProject = app.newProject();}" & return 
-                set line3 to "else{" & return + set line3 to "else{" & return 
-                set line4 to "var myProject = app.project;}" & return + set line4 to "var myProject = app.project;}" & return 
-                set line5 to "var theFile = \"" & this_item & "\";" & return + set line5 to "var theFile = \"" & this_item & "\";" & return 
-                set line6 to "var outFile = theFile.substring(0, theFile.lastIndexOf(\".\"));" & return + set line6 to "var outFile = theFile.substring(0, theFile.lastIndexOf(\".\"));" & return 
-                set line7 to "var c=0;" & return + set line7 to "time = new Date();" & return 
-                set line8 to "var cs=\"\";" & return + set line8 to "var tmpFile = \"~/AEtmp\"+time.getFullYear()+time.getMonth()+time.getDay()+time.getHours()+time.getMinutes()+time.getSeconds()+\".flv\";" & return 
-                set line9 to "do{" + set line9 to "var c=0;" & return 
-                set line10 to "if (c > 0) {cs = \"(\" + c.toString() + \")\"};" & return + set line10 to "var cs=\"\";" & return 
-                set line11 to "c=c+1;" & return + set line11 to "do{" 
-                set line12 to "} while (File(outFile + cs + \".flv\").exists)" & return + set line12 to "if (c > 0) {cs = \"(\" + c.toString() + \")\"};" & return 
-                set line13 to "var importOptions = new ImportOptions (new File (theFile));" & return + set line13 to "c=c+1;" & return 
-                set line14 to "if(importOptions.canImportAs(ImportAsType.FOOTAGE)){" & return + set line14 to "} while (File(outFile + cs + \".flv\").exists)" & return 
-                set line15 to "try{" + set line15 to "var importOptions = new ImportOptions (new File (theFile));" & return 
-                set line16 to "var myItem = myProject.importFile(importOptions);" & return + set line16 to "if(importOptions.canImportAs(ImportAsType.FOOTAGE)){" & return 
-                set line17 to "var newComp = myProject.items.addComp(\"rendercomp\",myItem.width,myItem.height,myItem.pixelAspect,myItem.duration, myItem.frameRate);" & return + set line17 to "try{" 
-                set line18 to "var VideoLayer = newComp.layers.add(myItem);" & return + set line18 to "var myItem = myProject.importFile(importOptions);" & return 
-                set line19 to "var AudioLayer = newComp.layers.add(myItem);" & return + set line19 to "var newComp = myProject.items.addComp(\"rendercomp\",myItem.width,myItem.height,myItem.pixelAspect,myItem.duration, myItem.frameRate);" & return 
-                set line20 to "AudioLayer.audioEnabled = false;" & return + set line20 to "var VideoLayer = newComp.layers.add(myItem);" & return 
-                set line21 to "VideoLayer.enabled = false;" & return + set line21 to "var AudioLayer = newComp.layers.add(myItem);" & return 
-                set line22 to "AudioLayer.startTime = AudioLayer.startTime - 3*(1/myItem.frameRate);" & return + set line22 to "AudioLayer.audioEnabled = false;" & return 
-                set line23 to "var rendQueue = myProject.renderQueue.items.add(newComp);" & return + set line23 to "VideoLayer.enabled = false;" & return 
-                set line24 to "var thisQueue = myProject.renderQueue.item(myProject.renderQueue.numItems);" & return + set line24 to "AudioLayer.startTime = AudioLayer.startTime - 3*(1/myItem.frameRate);" & return 
-                set line25 to "thisQueue.outputModules[1].applyTemplate(\"Adobe Flash Video\");" & return + set line25 to "var rendQueue = myProject.renderQueue.items.add(newComp);" & return 
-                set line26 to "thisQueue.outputModule(1).file = new File(outFile+cs+\".flv\");" & return + set line26 to "var thisQueue = myProject.renderQueue.item(myProject.renderQueue.numItems);" & return 
-                set line27 to "thisQueue.applyTemplate(\"Best Settings\");" & return + set line27 to "thisQueue.outputModules[1].applyTemplate(\"Adobe Flash Video\");" & return 
-                set line28 to "myProject.renderQueue.render();" & return + set line28 to "thisQueue.outputModule(1).file = new File(tmpFile);" & return 
-                set line29 to "newComp.remove();" & return + set line29 to "thisQueue.applyTemplate(\"Best Settings\");" & return 
-                set line30 to "myItem.remove();" & return + set line30 to "myProject.renderQueue.render();" & return 
-                set line31 to "}catch(e){" & return + set line31 to "newComp.remove();" & return 
-                set line32 to "}" & return + set line32 to "myItem.remove();" & return 
-                set line33 to "}" & return + set line33 to "var tempFile = File(tmpFile);" & return 
-                set mov2flv to line1 & line2 & line3 & line4 & line5 & line6 & line7 & line8 & line9 & line10 & line11 & line12 & line13 & line14 & line15 & line16 & line17 & line18 & line19 & line20 & line21 & line22 & line23 & line24 & line25 & line26 & line27 & line28 & line29 & line30 & line31 & line32 & line33 + set line34 to "tempFile.copy(outFile+cs+\".flv\");" & return 
-                DoScript mov2flv + set line35 to "tempFile.remove();" & return 
-                -- end After Effects script +  
-                 + set line36 to "}catch(e){" & return 
-            end timeout + set line37 to "}" & return 
-             + set line38 to "}" & return 
-            -- begin After Effects script: quit application + set mov2flv to line1 & line2 & line3 & line4 & line5 & line6 & line7 & line8 & line9 & line10 & line11 & line12 & line13 & line14 & line15 & line16 & line17 & line18 & line19 & line20 & line21 & line22 & line23 & line24 & line25 & line26 & line27 & line28 & line29 & line30 & line31 & line32 & line33 & line34 & line35 & line36 & line37 & line38 
-            set line1 to "myProject.close(CloseOptions.DO_NOT_SAVE_CHANGES);" & return + DoScript mov2flv 
-            set line2 to "app.quit();" & return + -- end After Effects script 
-            DoScript line1 & line2 with override +  
-            -- end After Effects script + end timeout 
-             +  
-            delay 5 + -- begin After Effects script: quit application 
-             + set line1 to "myProject.close(CloseOptions.DO_NOT_SAVE_CHANGES);" & return 
-        end tell + set line2 to "app.quit();" & return 
-    on error the error_message number the error_number + DoScript line1 & line2 with override 
-        display dialog "Error: " & the error_number & ". " & the error_message + -- end After Effects script 
-    end try+  
 + delay 5 
 +  
 + end tell 
 + on error the error_message number the error_number 
 + display dialog "Error: " & the error_number & ". " & the error_message 
 + end try
 end process_item end process_item
  
  
 on getFileName(thefile) on getFileName(thefile)
-    set {oldDelims, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {":"}} + set {oldDelims, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {":"}} 
-    set mytextfilename to last text item of (thefile as text) + set mytextfilename to last text item of (thefile as text) 
-    set AppleScript's text item delimiters to oldDelims + set AppleScript's text item delimiters to oldDelims 
-    return mytextfilename+ return mytextfilename
 end getFileName end getFileName
 </code> </code>
software/mov2flv.txt · Last modified: 2010/10/12 01:00 by admin