AppleScript mp4 Compression

Ein AppleScript mit dem man mehrere Files gleichzeitig in mp4 umwandeln kann. ffmpeg für Mac wird benötigt.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.