In verschiedenen Ordnern liegen MP4 Files. Das AppleScript soll einen Dialog öffnen in dem man die Ordner auswählen kann, ist nur ein Ordner ausgewählt wird geprüft ob sich ein MP4 File in diesem Ordner befindet, wenn ja wird gewarnt dass nur ein Ordner ausgewählt wurde, ist kein MP4 File vorhanden wird darauf hingewiesen und ein neuer Dialog wird geöffnet.
Sind mehrere Ordner ausgewählt werden diese an den Terminal geschickt. Der Terminal führt ein Shell Script aus, welches im AppleScript Verzeichnis (*.app/Contents/Resources/Scripts/) liegt. Das Shell Script soll dann die Ordner weiterverarbeiten.
set muxer toPOSIX pathof(path to resource "mxf-muxer"in directory "Scripts")set foldercount to0tellapplication"Finder"set FolderPath to(choose folderwith prompt "Pick the folders containing the files to process:"with multiple selections allowed)set foldercount tocount FolderPath
if(foldercount =1)thenset inPath toPOSIX pathof FolderPath astextset Foldername tonameoffolder FolderPath astextset infile to"no"tellapplication"Finder"toifexists inPath & Foldername &".MP4"asPOSIX filethenset infile to"yes"if(infile ="no")thendisplay dialog("There is no file: \""& inPath & Foldername &".MP4"astext)&"\". Please select (multiple) folders which contains MP4 files!"buttons{"Cancel", "Select Folders"} default button "Select Folders"if button returned ofresult="Select Folders"thenset FolderPath to(choose folderwith prompt "Pick the folders containing the files to process:"with multiple selections allowed)elsereturnendifelsedisplay dialog"You have only select one folder, are you sure that you only want to process one file?"buttons{"Select Folders", "Continue"} default button "Continue"if button returned ofresult="Select Folders"thenset FolderPath to(choose folderwith prompt "Pick the folders containing the files to process:"with multiple selections allowed)endifendifendifset filesString to""repeatwith file_ in FolderPath
set filesString to filesString &" ""ed formof(POSIX pathof file_)endrepeattellapplication"Terminal"activate
do scriptquoted formof muxer & filesString
endtellendtell
set muxer to POSIX path of (path to resource "mxf-muxer" in directory "Scripts")
set foldercount to 0
tell application "Finder"
set FolderPath to (choose folder with prompt "Pick the folders containing the files to process:" with multiple selections allowed)
set foldercount to count FolderPath
if (foldercount = 1) then
set inPath to POSIX path of FolderPath as text
set Foldername to name of folder FolderPath as text
set infile to "no"
tell application "Finder" to if exists inPath & Foldername & ".MP4" as POSIX file then set infile to "yes"
if (infile = "no") then
display dialog ("There is no file: \"" & inPath & Foldername & ".MP4" as text) & "\". Please select (multiple) folders which contains MP4 files!" buttons {"Cancel", "Select Folders"} default button "Select Folders"
if button returned of result = "Select Folders" then
set FolderPath to (choose folder with prompt "Pick the folders containing the files to process:" with multiple selections allowed)
else
return
end if
else
display dialog "You have only select one folder, are you sure that you only want to process one file?" buttons {"Select Folders", "Continue"} default button "Continue"
if button returned of result = "Select Folders" then
set FolderPath to (choose folder with prompt "Pick the folders containing the files to process:" with multiple selections allowed)
end if
end if
end if
set filesString to ""
repeat with file_ in FolderPath
set filesString to filesString & " " & quoted form of (POSIX path of file_)
end repeat
tell application "Terminal"
activate
do script quoted form of muxer & filesString
end tell
end tell
Ein kleines Script mit dem versteckte Dateien in OSX sichtbar bzw. unsichtbar machen kann.
Script mit der Endung .command abspeichern, im Terminal ausführbar machen mit: chmod +x scriptname.command
1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/bash
stat=`defaults read com.apple.finder AppleShowAllFiles`
if [ "$stat" == "NO" ]; then
defaults write com.apple.finder AppleShowAllFiles YES
killall Finder /System/Library/CoreServices/Finder.app
else
defaults write com.apple.finder AppleShowAllFiles NO
killall Finder /System/Library/CoreServices/Finder.app
fi
#!/bin/bash
stat=`defaults read com.apple.finder AppleShowAllFiles`
if [ "$stat" == "NO" ]; then
defaults write com.apple.finder AppleShowAllFiles YES
killall Finder /System/Library/CoreServices/Finder.app
else
defaults write com.apple.finder AppleShowAllFiles NO
killall Finder /System/Library/CoreServices/Finder.app
fi
set filecount to0onopen filelist
set filecount tocount filelist
if(filecount =2)thenset the_array to{}repeatwith i in filelist
set filename todo shell script ¬
"perl -e \"print quotemeta ('"&POSIX pathof i &"');\""setendof the_array to filename
endrepeatset firstfile toitem1of the_array
set secondfile toitem2of the_array
set revChar to reverse of(characters of firstfile)asstringset x to(offset of"."in revChar)+1set outname totext1thru-x of firstfile
set ext totext-4thru-1of firstfile
if(ext =".m2v"or ext =".ac3")thentellapplication"Terminal"activate
do script"/Applications/ffmpeg -filter:v yadif=0:0:0 -i "& firstfile &" -i "& secondfile &" -pix_fmt yuv420p -vcodec libx264 -crf 23 -preset slow -s 768x432 -sws_flags lanczos -acodec aac -strict experimental -ab 128k -threads 0 -y "& outname &"_x264.mp4"endtellendifelseif(filecount =1or filecount > 2)thenset the_array to{}repeatwith i in filelist
set filename todo shell script ¬
"perl -e \"print quotemeta ('"&POSIX pathof i &"');\""setendof the_array to filename &" "endrepeattellapplication"Terminal"activate
do script"for j in "& the_array &"; do /Applications/ffmpeg -filter:v yadif=0:0:0 -i \"$j\" -pix_fmt yuv420p -vcodec libx264 -crf 23 -preset slow -s 768x432 -sws_flags lanczos -acodec aac -strict experimental -ab 128k -threads 0 -y \"${j%.*}\"_x264.mp4; done"endtellendifendopenif filecount <1thendisplay dialog"Please Drag and Drop one Video Files or one Video and one Audio File for Compression in MP4 x264 on it!"returnendif
set filecount to 0
on open filelist
set filecount to count filelist
if (filecount = 2) then
set the_array to {}
repeat with i in filelist
set filename to do shell script ¬
"perl -e \"print quotemeta ('" & POSIX path of i & "');\""
set end of the_array to filename
end repeat
set firstfile to item 1 of the_array
set secondfile to item 2 of the_array
set revChar to reverse of (characters of firstfile) as string
set x to (offset of "." in revChar) + 1
set outname to text 1 thru -x of firstfile
set ext to text -4 thru -1 of firstfile
if (ext = ".m2v" or ext = ".ac3") then
tell application "Terminal"
activate
do script "/Applications/ffmpeg -filter:v yadif=0:0:0 -i " & firstfile & " -i " & secondfile & " -pix_fmt yuv420p -vcodec libx264 -crf 23 -preset slow -s 768x432 -sws_flags lanczos -acodec aac -strict experimental -ab 128k -threads 0 -y " & outname & "_x264.mp4"
end tell
end if
else if (filecount = 1 or filecount > 2) then
set the_array to {}
repeat with i in filelist
set filename to do shell script ¬
"perl -e \"print quotemeta ('" & POSIX path of i & "');\""
set end of the_array to filename & " "
end repeat
tell application "Terminal"
activate
do script "for j in " & the_array & "; do /Applications/ffmpeg -filter:v yadif=0:0:0 -i \"$j\" -pix_fmt yuv420p -vcodec libx264 -crf 23 -preset slow -s 768x432 -sws_flags lanczos -acodec aac -strict experimental -ab 128k -threads 0 -y \"${j%.*}\"_x264.mp4; done"
end tell
end if
end open
if filecount < 1 then
display dialog "Please Drag and Drop one Video Files or one Video and one Audio File for Compression in MP4 x264 on it!"
return
end if
Ein AppleScrit mit dem man ein Segment aus einem Videofile in mp4 und mp3 komprimiert und ein Frame extrahiert. das Script muss im AppleScript Editor als Programm abgespeichert werden. Anschließend können die Videofiles per Drag&Drop drauf gezogen werden. Es muss dann nur noch die Anfangszeit und die Endzeit in Form von 00:00:00.00 angegeben werden.
Hat man kein File, oder mehr als ein File ausgewählt wird eine Warnmeldung ausgegeben.
set filecount to0onopen infile
set filecount tocount infile
if(filecount > 1)thendisplay dialog"Please select only one file!"returnendifset filename todo shell script ¬
"perl -e \"print quotemeta ('"&POSIX pathof infile &"');\""set revChar to reverse of(characters of filename)asstringset x to(offset of"."in revChar)+1set outname totext1thru-x of filename
set StartFrame totext returned of(display dialog"Start Time:"with icon note default answer"00:15:00.24"buttons{"Cancel", "OK"} default button {"OK"})set EndTime totext returned of(display dialog"End Time:"with icon note default answer"01:00:00.24"buttons{"Cancel", "OK"} default button {"OK"})set ExtractFrame totext returned of(display dialog"Enter ExtractFrame:"with icon note default answer"00:00:30.10"buttons{"Cancel", "OK"} default button {"OK"})set std1 totext1thru2of StartFrame
set min1 totext4thru5of StartFrame
set sec1 totext7thru8of StartFrame
set fps1 totext10thru11of StartFrame
set stdtoframe to std1 *60*60*25set mintoframe to min1 *60*25set sectoframe to sec1 *25set framenum to stdtoframe + mintoframe + sectoframe + fps1
set std2 totext1thru2of EndTime
set min2 totext4thru5of EndTime
set sec2 totext7thru8of EndTime
set fps2 totext10thru11of EndTime
set stdtoframe2 to std2 *60*60*25set mintoframe2 to min2 *60*25set sectoframe2 to sec2 *25set framenum2 to stdtoframe2 + mintoframe2 + sectoframe2 + fps2
set FrameRange to framenum2 - framenum
set AppleScript's textitemdelimitersto","set endstd to FrameRange /25/60/60asstringset endstd totextitem1of endstd
set endmin to FrameRange /25/60- endstd *60asstringset endmin totextitem1of endmin
set endsec to FrameRange /25- endstd *3600- endmin *60asstringset endsec totextitem1of endsec
set endfps to round (FrameRange /25- endstd *3600- endmin *60- endsec)*25set timerange to endstd &":"& endmin &":"& endsec &"."& endfps
tellapplication"Terminal"activate
do script"/Applications/ffmpeg -ss "& StartFrame &" -t "& timerange &" -filter:v yadif=0:0:0 -i "& filename &" -pix_fmt yuv420p -vcodec libx264 -crf 23 -preset slower -s 384x216 -sws_flags lanczos -acodec aac -strict experimental -ac 1 -ar 44100 -ab 128k -threads 0 -y "& outname &".mp4; /Applications/ffmpeg -ss "& StartFrame &" -t "& timerange &" -i "& filename &" -vn -acodec libmp3lame -ac 1 -ar 44100 -ab 64k -y "& outname &".mp3; /Applications/ffmpeg -ss "& ExtractFrame &" -filter:v yadif=0:0:0 -i "& filename &" -frames 1 -s 500x280 -sws_flags lanczos -pix_fmt yuvj420p -sameq -y "& outname &"_"& ExtractFrame &".jpg; exit"endtellendopenif filecount <1thendisplay dialog"Please Drag and Drop Video File for Video / Audio Compression and Frame- Extraction for Website on it!"returnendif
set filecount to 0
on open infile
set filecount to count infile
if (filecount > 1) then
display dialog "Please select only one file!"
return
end if
set filename to do shell script ¬
"perl -e \"print quotemeta ('" & POSIX path of infile & "');\""
set revChar to reverse of (characters of filename) as string
set x to (offset of "." in revChar) + 1
set outname to text 1 thru -x of filename
set StartFrame to text returned of (display dialog "Start Time:" with icon note default answer "00:15:00.24" buttons {"Cancel", "OK"} default button {"OK"})
set EndTime to text returned of (display dialog "End Time:" with icon note default answer "01:00:00.24" buttons {"Cancel", "OK"} default button {"OK"})
set ExtractFrame to text returned of (display dialog "Enter ExtractFrame:" with icon note default answer "00:00:30.10" buttons {"Cancel", "OK"} default button {"OK"})
set std1 to text 1 thru 2 of StartFrame
set min1 to text 4 thru 5 of StartFrame
set sec1 to text 7 thru 8 of StartFrame
set fps1 to text 10 thru 11 of StartFrame
set stdtoframe to std1 * 60 * 60 * 25
set mintoframe to min1 * 60 * 25
set sectoframe to sec1 * 25
set framenum to stdtoframe + mintoframe + sectoframe + fps1
set std2 to text 1 thru 2 of EndTime
set min2 to text 4 thru 5 of EndTime
set sec2 to text 7 thru 8 of EndTime
set fps2 to text 10 thru 11 of EndTime
set stdtoframe2 to std2 * 60 * 60 * 25
set mintoframe2 to min2 * 60 * 25
set sectoframe2 to sec2 * 25
set framenum2 to stdtoframe2 + mintoframe2 + sectoframe2 + fps2
set FrameRange to framenum2 - framenum
set AppleScript's text item delimiters to ","
set endstd to FrameRange / 25 / 60 / 60 as string
set endstd to text item 1 of endstd
set endmin to FrameRange / 25 / 60 - endstd * 60 as string
set endmin to text item 1 of endmin
set endsec to FrameRange / 25 - endstd * 3600 - endmin * 60 as string
set endsec to text item 1 of endsec
set endfps to round (FrameRange / 25 - endstd * 3600 - endmin * 60 - endsec) * 25
set timerange to endstd & ":" & endmin & ":" & endsec & "." & endfps
tell application "Terminal"
activate
do script "/Applications/ffmpeg -ss " & StartFrame & " -t " & timerange & " -filter:v yadif=0:0:0 -i " & filename & " -pix_fmt yuv420p -vcodec libx264 -crf 23 -preset slower -s 384x216 -sws_flags lanczos -acodec aac -strict experimental -ac 1 -ar 44100 -ab 128k -threads 0 -y " & outname & ".mp4; /Applications/ffmpeg -ss " & StartFrame & " -t " & timerange & " -i " & filename & " -vn -acodec libmp3lame -ac 1 -ar 44100 -ab 64k -y " & outname & ".mp3; /Applications/ffmpeg -ss " & ExtractFrame & " -filter:v yadif=0:0:0 -i " & filename & " -frames 1 -s 500x280 -sws_flags lanczos -pix_fmt yuvj420p -sameq -y " & outname & "_" & ExtractFrame & ".jpg; exit"
end tell
end open
if filecount < 1 then
display dialog "Please Drag and Drop Video File for Video / Audio Compression and Frame- Extraction for Website on it!"
return
end if
Verschiedenes zu Batch, Shell, Linux, Python, ffmpeg, maxscript, 3d, rendering und vfx