在 while 读取循环中读取输入似乎不起作用
while read line
do
echo "get some input from the user"
read response
done < some_file.txt
Run Code Online (Sandbox Code Playgroud)
执行不会像读取在循环之外那样暂停。为什么是这样?是否有在 while 读取循环中读取输入的解决方法?
如果我有:
for i in *.mov;
do
ffmpeg -y -i $i -c:v copy -c:a copy ${i%%.mov}.mp4
done
Run Code Online (Sandbox Code Playgroud)
这运行良好。但如果我跑:
find . -name "*.ts" -print0 | while read -d $'\0' file;
do
ffmpeg -i "$file" -c copy -map 0 "${file%%.ts}_rec.mp4";
done
Run Code Online (Sandbox Code Playgroud)
这失败了。我需要输入-nostdin。
find . -name "*.ts" -print0 | while read -d $'\0' file;
do
ffmpeg -nostdin -i "$file" -c copy -map 0 "${file%%.ts}_rec.mp4";
done
Run Code Online (Sandbox Code Playgroud)
文档解释说,这会禁用标准输入上的交互,并且对后台进程很有帮助。
为什么在第二种情况下 FFmpeg 是后台进程?或者还有其他问题吗?