• atwiki
  • ProMemo
  • ffmpegで動画変換-AppleScript一つ前との差分

「ffmpegで動画変換-AppleScript」の編集履歴(バックアップ)一覧はこちら

ffmpegで動画変換-AppleScript - (2009/10/20 (火) 17:46:40) の1つ前との変更点

追加された行は緑色になります。

削除された行は赤色になります。

*&this_page() |&tags()|解説|最終更新日 &date() : View &counter(total)|&link_pdf(text=PDFで表示)|ダウンロード|View &counter(total)| AppleScriptからffmpegを使って動画変換。.app形式なのにソースコードいじれるらしい。 起動するとファイル選択画面が表示されてファイル指定(アイコン上にファイルをドロップしてもよし) →返還後の形式を選択 #contents *ffconvert.app - 「ここを編集(1)」でffmpegのパスを指定 - 変換形式を増やすときには「ここを編集(1),(2),(3)」を修正 on convert(srcFile) --初期設定 ----ここを編集(1) set ffmpeg to "/usr/local/bin/ffmpeg" as string --set 形式command to ffmpeg & " -y -i \"srcFilePath\" ffmpegの変換コマンド \"distFilePath\"" set mp3command to ffmpeg & " -y -i \"srcFilePath\" -acodec libmp3lame -vn \"distFilePath\"" set mp4command to ffmpeg & " -y -i \"srcFilePath\" -acodec libfaac -vcodec mpeg4 \"distFilePath\"" set wmvcommand to ffmpeg & " -y -i \"srcFilePath\" -acodec wmav2 -vcodec wmv1 \"distFilePath\"" ----ここまで編集(1) --変換するファイルのパス set srcFilePath to POSIX path of srcFile tell application "System Events" --変換するファイルのファイル名 get name of file srcFilePath set srcFileName to (result as string) --変換するファイルの拡張子 get name extension of file srcFilePath set srcFileType to (result as string) end tell --変換形式の選択 ----ここを編集(2) display dialog (srcFileName as string) & " (" & srcFileType & ")を以下の形式に変換" buttons {"mp3", "mp4", "wmv"} default button 1 ----ここまで編集(2) --変換後のファイルの拡張子 set distFileType to button returned of result --変換後のファイルのファイル名 set distFileName to replaceText(srcFileName, "." & srcFileType, "." & distFileType) --変換後のファイルのパス set distFilePath to replaceText(srcFilePath, srcFileName, distFileName) --変換実行 ---- ここを編集(3) if distFileType is "mp3" then execFFmpegCommand(mp3command, srcFilePath, distFilePath) else if distFileType is "mp4" then execFFmpegCommand(mp4command, srcFilePath, distFilePath) else if distFileType is "mwmv" then execFFmpegCommand(wmvcommand, srcFilePath, distFilePath) end if ---- ここまで編集(3) beep 3 display dialog (srcFileName as string) & "が完成しました。" end convert --サブルーチン達 ----コマンド実行 on execFFmpegCommand(command, srcFilePath, distFilePath) set command to replaceText(command, "srcFilePath", srcFilePath) set command to replaceText(command, "distFilePath", distFilePath) --display dialog command do shell script command end execFFmpegCommand ----文字列置換 on replaceText(theText, serchStr, replaceStr) set tmp to AppleScript's text item delimiters set AppleScript's text item delimiters to serchStr set theList to every text item of theText set AppleScript's text item delimiters to replaceStr set theText to theList as string set AppleScript's text item delimiters to tmp return theText end replaceText --ファイルがドロップされたとき on open (droppedItem) convert(droppedItem) end open --スクリプトが実行された時 on run --変換するファイルの選択 set selectFile to choose file with prompt "変換するファイルを選択してください" convert(selectFile) end run *実行方法 ダブルクリックで起動 *実行結果 - ダブルクリックで起動された時 ファイル選択ウィンドウ表示 -> 変換後の形式を選択 - アイコンにファイルがドロップされた時 変換後の形式を選択 *テスト環境 AppleScriptなのでMac専用 ----
*&this_page() |&tags()|解説|最終更新日 &date() : View &counter(total)|&link_pdf(text=PDFで表示)|[[ダウンロード>http://www20.atwiki.jp/yosilove/?cmd=upload&act=open&page=ffmpegで動画変換-AppleScript&file=ffconvert.app]]|View &counter(total)| AppleScriptからffmpegを使って動画変換。.app形式なのにソースコードいじれるらしい。 起動するとファイル選択画面が表示されてファイル指定(アイコン上にファイルをドロップしてもよし) →返還後の形式を選択 #contents *ffconvert.app - 「ここを編集(1)」でffmpegのパスを指定 - 変換形式を増やすときには「ここを編集(1),(2),(3)」を修正 on convert(srcFile) --初期設定 ----ここを編集(1) set ffmpeg to "/usr/local/bin/ffmpeg" as string --set 形式command to ffmpeg & " -y -i \"srcFilePath\" ffmpegの変換コマンド \"distFilePath\"" set mp3command to ffmpeg & " -y -i \"srcFilePath\" -acodec libmp3lame -vn \"distFilePath\"" set mp4command to ffmpeg & " -y -i \"srcFilePath\" -acodec libfaac -vcodec mpeg4 \"distFilePath\"" set wmvcommand to ffmpeg & " -y -i \"srcFilePath\" -acodec wmav2 -vcodec wmv1 \"distFilePath\"" ----ここまで編集(1) --変換するファイルのパス set srcFilePath to POSIX path of srcFile tell application "System Events" --変換するファイルのファイル名 get name of file srcFilePath set srcFileName to (result as string) --変換するファイルの拡張子 get name extension of file srcFilePath set srcFileType to (result as string) end tell --変換形式の選択 ----ここを編集(2) display dialog (srcFileName as string) & " (" & srcFileType & ")を以下の形式に変換" buttons {"mp3", "mp4", "wmv"} default button 1 ----ここまで編集(2) --変換後のファイルの拡張子 set distFileType to button returned of result --変換後のファイルのファイル名 set distFileName to replaceText(srcFileName, "." & srcFileType, "." & distFileType) --変換後のファイルのパス set distFilePath to replaceText(srcFilePath, srcFileName, distFileName) --変換実行 ---- ここを編集(3) if distFileType is "mp3" then execFFmpegCommand(mp3command, srcFilePath, distFilePath) else if distFileType is "mp4" then execFFmpegCommand(mp4command, srcFilePath, distFilePath) else if distFileType is "mwmv" then execFFmpegCommand(wmvcommand, srcFilePath, distFilePath) end if ---- ここまで編集(3) beep 3 display dialog (srcFileName as string) & "が完成しました。" end convert --サブルーチン達 ----コマンド実行 on execFFmpegCommand(command, srcFilePath, distFilePath) set command to replaceText(command, "srcFilePath", srcFilePath) set command to replaceText(command, "distFilePath", distFilePath) --display dialog command do shell script command end execFFmpegCommand ----文字列置換 on replaceText(theText, serchStr, replaceStr) set tmp to AppleScript's text item delimiters set AppleScript's text item delimiters to serchStr set theList to every text item of theText set AppleScript's text item delimiters to replaceStr set theText to theList as string set AppleScript's text item delimiters to tmp return theText end replaceText --ファイルがドロップされたとき on open (droppedItem) convert(droppedItem) end open --スクリプトが実行された時 on run --変換するファイルの選択 set selectFile to choose file with prompt "変換するファイルを選択してください" convert(selectFile) end run *実行方法 ダブルクリックで起動 *実行結果 - ダブルクリックで起動された時 ファイル選択ウィンドウ表示 -> 変換後の形式を選択 - アイコンにファイルがドロップされた時 変換後の形式を選択 *テスト環境 AppleScriptなのでMac専用 ----

表示オプション

横に並べて表示:
変化行の前後のみ表示:
目安箱バナー