簡體   English   中英

AUTOMATOR-嘗試在Shell腳本中發出帶有從AppleScript接收的參數的命令

[英]AUTOMATOR - Trying to issue a command inside a shell script with parameters received from AppleScript

我正在為macOS創建此自動腳本,該腳本接收視頻並在幾秒鍾內的給定時間提取幀。

從finder接收視頻后,它將運行此applescript,要求輸入時間(以秒為單位)以提取幀。

時間存儲在Applescript變量“ seconds”中。

當applescript結束時,我有3個變量:

  1. inputVideo,包含POSIX輸入視頻路徑
  2. outputVideo,包含POSIX輸出視頻路徑
  3. 秒,包含以秒為單位的時間。

小標題以這些行結尾

    return fileInputPosix & fileOutputPosix & seconds
end run

並將變量傳遞到以以下幾行開頭的shell腳本:

fileInput=${@[0]}
fileOutput=${@[1]}
seconds=${@[2]}

/usr/local/bin/ffmpeg -i $fileInput -vf "select=eq(n\,$seconds)" -vframes 1 $fileOutput

最后一行使用FFMPEG提取幀。

我有這個錯誤

“運行Shell腳本”操作遇到錯誤:“ ffmpeg版本4.1版權所有(c)2000-2018年,使用Apple LLVM版本10.0.0(clang-1000.11.45.5)構建的FFmpeg開發人員配置:--prefix = / usr / local /Cellar/ffmpeg/4.1_1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc = clang --host-cflags = --host-ldflags = --enable-ffplay --enable-gpl --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable- libx265 --enable-libxvid --enable-lzma --enable-opencl --enable-videotoolbox libavutil 56. 22.100 / 56. 22.100 libavcodec 58. 35.100 / 58. 35.100 libavformat 58. 20.100 / 58. 20.100 libavdevice 58. 5.100 / 58. 5.100 libavfilter 7. 40.101 / 7. 40.101 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 3.100 / 5. 3.100 libswresample 3. 3.100 / 3. 3.100 libpostproc 55. 3.100 / 55. 3.100 / Users /火球/桌面/ HD / aaa.mp4 /用戶/火球/桌面/ HD / aaa.png1000 [0]: 不是目錄”

我想我在命令行字符串上有一些串聯錯誤

如果要在終端上鍵入最后一行,則應輸入以下內容:

ffmpeg -i aaa.mp4 -vf "select=eq(n\,1000)" -vframes 1 aaa.png

其中aaa.mp4是輸入視頻,而aaa.png是t = 1000s處的幀。

有任何想法嗎?

根據錯誤消息,行fileInputPosix & fileOutputPosix & seconds返回一個單個字符串。

也許您想返回一個列表,那么您必須添加大括號並用逗號替換&字符,並且必須將數值轉換為文本

return {fileInputPosix, fileOutputPosix, (seconds as text)}

要將變量傳遞給shell腳本,只需編寫

/usr/local/bin/ffmpeg -I $1 -vf "select=eq(n\,$3)" -vframes 1 $2

或者如果您需要變量

fileInput=$1
fileOutput=$2
seconds=$3

/usr/local/bin/ffmpeg -i $fileInput -vf "select=eq(n\,$seconds)" -vframes 1 $fileOutput

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM