Bash while loop stops for no reason? [duplicate]

﹥>﹥吖頭↗ 提交于 2019-12-17 21:35:44

问题


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.

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.


回答1:


Use

</dev/null ffmpeg ...
</dev/null ffmpeg ... 

or

ffmpeg ... </dev/null
ffmpeg ... </dev/null

to prevent ffmpeg reading from rotatelist_2 via stdin.



来源:https://stackoverflow.com/questions/28159381/bash-while-loop-stops-for-no-reason

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!