Bash while 循环无缘无故停止? [英] Bash while loop stops for no reason?
问题描述
我运行以下 bash 脚本来旋转我的手机视频
I run the following bash script to rotate my mobile phone vids
while read filename ; do
nf=$(echo $filename |rev | cut -f1 -d '/'|cut -f2- -d '.' |rev)
echo $nf
rm -f ffmpeg2pass-0.log
rm -f rotate/tmp.avi
ffmpeg -i $filename -c:v libxvid -pass 1 -c:a libmp3lame -qscale:a 4 -vf "transpose=2,transpose=2" "rotate/tmp.avi"
ffmpeg -i $filename -c:v libxvid -pass 2 -c:a libmp3lame -qscale:a 4 -vf "transpose=2,transpose=2" "rotate/$nf.avi"
done <rotatelist_2
我知道有更好的方法可以做到这一点;我把它放在一起,但我正在弄清楚如何正确地制作视频,这样其余的就不需要看起来不错;-))
I know there are better ways to do this; I budged this together but I'm figuring out how to do the videos right so the rest don't need to look nice ;-))
然而,在第一次运行后,循环意外结束,没有错误消息.我为其他工作得很好的东西运行了类似的循环.
However after the first run, the loop unexpectedly ends with no error message. I run similar loops for other things which work pretty well.
回声不再被调用,所以我猜循环本身有问题.列表中的换行符是0x0A,所以应该没问题.
The echo is not called again so I guess there's something wrong with the loop itself. The linebreak in the list is a 0x0A, so it should be ok.
推荐答案
使用
</dev/null ffmpeg ...
</dev/null ffmpeg ...
或
ffmpeg ... </dev/null
ffmpeg ... </dev/null
防止通过标准输入从rotatelist_2读取ffmpeg.
to prevent ffmpeg reading from rotatelist_2 via stdin.
这篇关于Bash while 循环无缘无故停止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!