gpt4 book ai didi

shell - 从 Shell 脚本/bin/sh 运行 FFMPEG

转载 作者:行者123 更新时间:2023-12-04 23:05:09 28 4
gpt4 key购买 nike

我正在尝试设置一个 Shell 脚本以在自动机监视文件夹中工作...

除了 Run Shell Scrip 部分外,一切都有效......

本质上,当文件出现在监视文件夹中时,它会运行调用 FFMPEG 的 shell 脚本,然后将文件移动到存档文件夹以进行安全保存。但是现在自动机告诉我一切正常,但现在正在创建文件。

我将 Shell 设置为/bin/sh 并将输入设置为参数

这是我的脚本:

for f in "$@"
do
name=$(basename "$f")
dir=$(dirname "$f")
ffmpeg -i "$f" -b 250k -strict experimental -deinterlace -vcodec h264 -acodec aac "$dir/mp4/${name%.*}.mp4"
echo "$dir/mp4/${name%.*}.mp4"
done

它确实回显了正确的文件名,但实际上并没有运行 ffmpeg

我已尝试添加 -exec之前就像我在一些脚本中看到的那样,但仍然没有......

最佳答案

FFmpeg 在运行时搜索 STDIN。这是为了允许用户点击 q停止编码,以及其他任务。这可能会导致脚本出现问题。也许解决方法试试这个:

# notice --+
# |
# v
ffmpeg -nostdin -i "$f" -b 250k -strict experimental -deinterlace \
-vcodec h264 -acodec aac "$dir/mp4/${name%.*}.mp4"

mysterious error with ffmpeg on OSX

关于shell - 从 Shell 脚本/bin/sh 运行 FFMPEG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14866436/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com