Hey guys!
I’m trying to create a script droplet to sit on my desktop.
(I will drag a video file onto it.)
A new folder must be created on the desktop (with the same name as the video file)
Within this folder, the video clips (of max length 30 seconds) from the original video, labelled 1, 2, 3, … must be saved. It’s for posting to WhatsApp status, it only accepts videos of max 30 seconds.
I am a Computer Science student but have never used Scripts before, somebody wrote this up for me but doesn’t seem to want to help me finish. Any advice & fixes would be appreciated!
e.g. a 3-minute video (example.mp4) is dragged onto the application. This would result in 6x 30-second videos (labelled 1-6.mp4) in a folder called “example” on my desktop.
e.g. a 75-second video would result in 3 videos (2x 30 seconds & 1x 15 second video)
This is the script I’m working with so far, and I’m getting export errors (see below)
“End time must be less than or equal to duration
QuickTime Player got an error: End time must be less than or equal to duration (6)”
on open droppedItems
tell application "Finder" to repeat with item_ in droppedItems
end repeat
set UnixPath to POSIX path of ((path to me as text) & "::")
tell application "QuickTime Player"
activate
open (POSIX path of item_) as POSIX file
set videoDuration to duration of document 1
set fileName to name of document 1
end tell
set startTime to 0
set i to 1
repeat while (startTime + 30) is less than videoDuration
tell application "QuickTime Player"
trim document 1 from startTime to (startTime + 30)
export document 1 in (UnixPath & "/Output/" & i & "-" & fileName as POSIX file) using settings preset "720p"
close document 1 saving no
open (POSIX path of item_) as POSIX file
set i to i + 1
end tell
set startTime to (startTime + 30)
end repeat
tell application "QuickTime Player"
trim document 1 from startTime to (videoDuration - 1)
export document 1 in (UnixPath & "/Output/" & i & "-" & fileName as POSIX file) using settings preset "720p"
close document 1 saving no
end tell
tell application "QuickTime Player" to close window "Export Progress"
end open