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.
So, does ffmpeg affect the bash pipe?
Caveat: I've never used
ffmpeg
, but in working with other questions concerning the program, it appears that, likessh
,ffmpeg
reads from standard input without actually using it, so the first call toConvert
is consuming the rest of the file list afterread
gets the first line. Try thisThis way,
ffmpeg
will not "hijack" data from standard input intended forread
command.Never use this syntax :
This syntax read the output of a command word by word and not row by row which often creates unexpected problems (like when row contain some spaces and when you want read a row like an item for example).
There always is a smarter solution :
I wrote a course with more details about this subject and recurring errors, but in French, unfortunately :)
To answer the original question, you could use something like :
KISS ! =)