bash 管道中的 ffmpeg [英] ffmpeg in a bash pipe
问题描述
我有一个 rmvb 文件路径列表,想将这些文件转换为 mp4 文件.所以我希望使用bash管道来处理它.代码是
I have a rmvb file path list, and want to convert this files to mp4 files. So I hope to use bash pipeline to handle it. The code is
Convert() {
ffmpeg -i "$1" -vcodec mpeg4 -sameq -acodec aac -strict experimental "$1.mp4"
}
Convert_loop(){
while read line; do
Convert $line
done
}
cat list.txt | Convert_loop
然而,它只处理第一个文件并且管道退出.
However, it only handle the first file and the pipe exits.
那么,ffmpeg 会影响 bash 管道吗?
So, does ffmpeg affect the bash pipe?
推荐答案
警告:我从未使用过 ffmpeg
,但在处理有关该程序的其他问题时,似乎像 ssh
, ffmpeg
从标准输入读取而不实际使用它,因此对 Convert
的第一次调用在 read 之后消耗了文件列表的其余部分
获取第一行.试试这个
Caveat: I've never used ffmpeg
, but in working with other questions concerning the program, it appears that, like ssh
, ffmpeg
reads from standard input without actually using it, so the first call to Convert
is consuming the rest of the file list after read
gets the first line. Try this
Convert() {
ffmpeg -i "$1" -vcodec mpe4 -sameq -acodec aac
-strict experimental "$1.mp4" < /dev/null
}
这样,ffmpeg
不会从用于 read
命令的标准输入中劫持"数据.
This way, ffmpeg
will not "hijack" data from standard input intended for read
command.
这篇关于bash 管道中的 ffmpeg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!