-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode
78 lines (53 loc) · 2.29 KB
/
code
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
global itemCount
global completedCount
-- replace text function to swap filetypes
on replace_text1(this_text, search_string, replacement_string) -- handler name changed from the book only to facilitate production of this file
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to {""}
return this_text
end replace_text1
on open theDroppedItems
set itemCount to count of theDroppedItems
set completedCount to 1
repeat with a from 1 to count of theDroppedItems
set theCurrentItem to item a of theDroppedItems
processItem(theCurrentItem)
end repeat
end open
on processItem(theItem)
set DeleteOriginal to true
set OriginalMovieLocation to quoted form of POSIX path of theItem
set NewMovieLocation to OriginalMovieLocation
set NewMovieLocation to replace_text1(NewMovieLocation, ".mkv", ".mp4")
set NewMovieLocation to replace_text1(NewMovieLocation, ".mov", ".mp4")
set NewMovieLocation to replace_text1(NewMovieLocation, ".avi", ".mp4")
set NewMovieLocation to replace_text1(NewMovieLocation, ".wmv", ".mp4")
set NewMovieLocation to replace_text1(NewMovieLocation, ".flv", ".mp4")
set NewerrorLocation to replace_text1(NewMovieLocation, ".mp4", ".log")
-- display dialog OriginalMovieLocation
-- display dialog NewMovieLocation
--display dialog itemCount
--HANDLE PROGRESS BAR
set progress total steps to itemCount
set progress completed steps to completedCount
set progress description to "Remuxing Movie"
delay 1.5
try
do shell script "/usr/local/bin/ffmpeg -v quiet -stats -i " & OriginalMovieLocation & " -acodec copy -vcodec copy " & NewMovieLocation & " -f null - 2>" & NewerrorLocation
on error errStr number errorNumber
display dialog "The original appears to be damaged, it will be left untouched"
set DeleteOriginal to false
end try
if DeleteOriginal is true then
set progress description to "Deleting Originals"
delay 1.5
-- delete the file
do shell script "rm " & OriginalMovieLocation
do shell script "rm " & NewerrorLocation
end if
-- add another number to progress bar
set completedCount to completedCount + 1
end processItem