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
防止ffmpeg通过stdin从rotatelist_2中读取.
to prevent ffmpeg reading from rotatelist_2 via stdin.
这篇关于Bash while循环无缘无故停止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!