Hey!
I'm trying to make my life a whole lot easier by making a bash-script, who reads a directory and greps the files that ends on mpg and mpeg, defined in a pattern.temp written by the script.
The script was designed for converting musicvideos into compliant DVD-files.
When reading (a lot of) files, the script runs smoothly the first time, but when trying to run the commands on the second file, ffmpeg somehow enforces the script to quit.
I've tried to comment out the ffmpeg line, and then the script runs just fine (even though it is useless without the ffmpeg command).
Could it be an issue with the way ffmpeg interprets the syntax's?
Hope some of you can help me, because it is starting to drive me crazy :P
Best regards
trex_dk
Code:
#!/bin/sh
if [ "$1" = "" ]; then
echo "Specify directory containing mpegs"
else
if [ ! -d $1 ]; then
echo "Directory does not exist!"
exit 0
fi
if [ -e patterns.temp ]; then
rm patterns.temp
fi
touch patterns.temp
echo ".mpg" > patterns.temp
echo ".mpeg" >> patterns.temp
numVideos=`ls $1 | grep -f patterns.temp | wc -l`
i=1
ls $1 | grep -f patterns.temp | while read file; do
if [ -f "$1/$file" ]; then
echo "-- $file ($i / $numVideos) --"
echo "> Processing audio"
ffmpeg -i "$1/$file" -ab 256 -ar 48000 -ac 2 -acodec ac3 -y "$1/$file.ac3"
echo "> Processing video"
mpegdemux -d -s 0xe0 "$1/$file" "$1/$file.m2v"
echo "> Multiplexing"
mplex -f 8 -o "$1/final_$file" "$1/$file.m2v" "$1/$file.ac3"
rm -f "$1/$file.ac3" "$1/$file.m2v"
echo "> DONE!"
i=`expr $i + 1`
fi
done
rm patterns.temp
fi
exit 0