创建自动ffmpeg转换器

时间:2019-01-27 14:28:51

标签: bash ffmpeg terminal automator

我正在尝试使用ffmpeg创建一个自动化过程,并且在理解如何使代码适应自动化方面遇到问题。

该代码在终端中可以正常工作,但是需要我手动输入每个文件名。我正在尝试使过程自动化。

for f in "$@"
do

FILE= "$f"
OUT=${FILE/mp4/png}
OUT_WIDTH=10800
OUT_HEIGHT=3600

eval $(ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height,width "${FILE}")
IN_WIDTH=${streams_stream_0_width}
IN_HEIGHT=${streams_stream_0_height}

 eval $(ffprobe -v error -of flat=s=_ -count_frames -select_streams v:0 -show_entries stream=nb_read_frames "${FILE}")
IN_FRAMES=${streams_stream_0_nb_read_frames}

W_TILES=$(bc <<< "(sqrt($OUT_WIDTH*$IN_FRAMES*$IN_HEIGHT/($IN_WIDTH*$OUT_HEIGHT))+3)")
H_TILES=$(bc <<< "(sqrt($OUT_HEIGHT*$IN_FRAMES*$IN_WIDTH/($OUT_WIDTH*$IN_HEIGHT)))")

W_SHRUNK=$(bc <<< "$OUT_WIDTH/$W_TILES")
H_SHRUNK=$(bc <<< "$OUT_HEIGHT/$H_TILES")

ffmpeg -i "${FILE}" -vf "hflip,transpose=cclock,scale=${H_SHRUNK}:${W_SHRUNK},tile=${H_TILES}x${W_TILES},transpose=clock,hflip,scale=${OUT_WIDTH}x${OUT_HEIGHT}" -an -sn -vsync 0 "${OUT}"


done

我希望代码能产生胶片每一帧的图像。但是相反,我收到了大量错误消息。

The action “Run Shell Script” encountered an error: “-: line 5: /Users/jeffreymoser/21 A New Dawn.mp4: Permission denied
-: line 14: ffprobe: command not found
-: line 18: ffprobe: command not found
(standard_in) 1: parse error
(standard_in) 1: parse error
(standard_in) 1: parse error
(standard_in) 2: parse error
(standard_in) 2: parse error
-: line 29: ffmpeg: command not found
-: line 5: /Users/jeffreymoser/22 Battle Hymn.mp4: Permission denied
-: line 14: ffprobe: command not found
-: line 18: ffprobe: command not found
(standard_in) 1: parse error
(standard_in) 1: parse error
(standard_in) 1: parse error
(standard_in) 2: parse error
(standard_in) 2: parse error
-: line 29: ffmpeg: command not found
-: line 5: /Users/jeffreymoser/23 Reckless.mp4: Permission denied
-: line 14: ffprobe: command not found
-: line 18: ffprobe: command not found
(standard_in) 1: parse error
(standard_in) 1: parse error
(standard_in) 1: parse error
(standard_in) 2: parse error
(standard_in) 2: parse error
-: line 29: ffmpeg: command not found
-: line 5: /Users/jeffreymoser/24 Showdown.mp4: Permission denied
-: line 14: ffprobe: command not found
-: line 18: ffprobe: command not found
(standard_in) 1: parse error
(standard_in) 1: parse error
(standard_in) 1: parse error
(standard_in) 2: parse error
(standard_in) 2: parse error
-: line 29: ffmpeg: command not found
-: line 5: /Users/jeffreymoser/25 Wedding Bells.mp4: Permission denied
-: line 14: ffprobe: command not found
-: line 18: ffprobe: command not found
(standard_in) 1: parse error
(standard_in) 1: parse error
(standard_in) 1: parse error
(standard_in) 2: parse error
(standard_in) 2: parse error
-: line 29: ffmpeg: command not found

0 个答案:

没有答案