从Shell脚本/ bin / sh运行FFMPEG [英] Running FFMPEG from Shell Script /bin/sh

查看:1013
本文介绍了从Shell脚本/ bin / sh运行FFMPEG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



除了运行Shell Scrip部分外,所有内容都可以正常工作



本质上,当文件显示在watch文件夹中时,它运行调用FFMPEG的shell脚本,然后将文件移动到归档文件夹以保持安全。然而,现在,自动化程序告诉我一切正常,但现在正在创建文件。



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

p>

这是我的脚本:

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

它会回显正确的文件名,但实际上并不运行ffmpeg



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

解决方案

不知道是不是因为我在Mac OS X Server上运行,但我想像是,我不得不将绝对路径包含在ffmpeg ...中固定



$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ )
dir = $(dirname$ f)
/ op t / local / bin / ffmpeg -i$ f-b 250k -strict experiment -deinterlace -vcodec h264 -acodec aac$ dir / mp4 / $ {name%。*} mp4
echo$ dir / mp4 / $ {name%。*}。mp4
done


I am trying to setup a Shell Script to work within an automator watch folder...

Everything works with the exception of the Run Shell Scrip portion...

Essentially when a file shows up in the watch folder, it runs the shell scrip which calls FFMPEG and then will move the file to an archive folder for safe keeping. However right now automator is telling me everything worked but now file is being created.

I have the Shell set to /bin/sh and Pass input set to as arguments

Here is my script:

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

it does echo the correct filename, but does not actually run ffmpeg

I have tried adding -exec before it like I have seen in some scripts but still nothing...

解决方案

Not sure if it is because I am running on a Mac OS X Server but I imagine it is, I had to include the absolute path to ffmpeg...which fixed it

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

这篇关于从Shell脚本/ bin / sh运行FFMPEG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆