Applescript

2014.02.03

AppleScriptでmp4の不要な部分を一括カット

この記事は3728日前に投稿されたものです。

ムービーの一括トリミング!

大量にあるムービーを決まった尺で切り出したい!という場面に出くわし、
いろいろ参考にさせていただきました。

Apple scriptでムービーをトリミング

set secondsFromStart to 10
set secondsFromEnd to 10
set srcFolder to choose folder
set dstFolder to choose folder with prompt "書き出し先を選んでください。" default location srcFolder

tell application "Finder"
	set fileList to files of folder srcFolder
end tell

repeat with f in fileList
	tell application "QuickTime Player"
		open f
		set documentName to name of f
		delay (1.0)
		tell document 1
			trim from secondsFromStart to (duration - secondsFromEnd)
			export in file ((dstFolder as text) & documentName) using settings preset "480p..."
			close saving no
			delay (1.0)
		end tell
	end tell
end repeat

解説

上のスクリプトは、
ムービーの入ったフォルダを選ぶ → 書き出すフォルダを選ぶ
→ トリミング(開始の10秒と終了の10秒をカット) → プリセット「480…」で書き出し
ということです。

トリミング

trim from 開始(秒) to 終了(秒)

書き出し

export in ファイル名 using settings preset "プリセット"

まとめ

このやり方だと、決まった秒数のオープニングやエンディングを自動的にカットできて便利ですね。
ちなみに、QuickTimeは書き出しがプリセットのみのようです。
任意のサイズのプリセットも作れるようですが・・・、ちょいめんどいです。

※自己責任でお願いします!