i have this piece of code
for f in ${CURRENT_IMAGE_FILES[@]};
do
echo "Checking if too many process are running"
while :
do
RUNNING_PROCESS=`ps aux | grep [f]fmpeg -c`
if [[ $RUNNING_PROCESS -gt 22 ]]
then
echo "Too many process running now, sleep for 1 second"
sleep 1
else
echo "Total ffmpeg process running is less then 20, continue"
echo "current process count is " $RUNNING_PROCESS
break
fi
done
convert $f -resize 1280x720 -gravity center $f
composite -gravity center $f /var/bash/b.jpg $f
ffmpeg -loop 1 -f image2 -i $f -c:v libx264 -pix_fmt yuvj420p -preset ultrafast -t 3 $DIR/$COUNT.mp4 &
((++COUNT))
done
The thing is that when place inside the for loop, grep command is getting an error. Something along the lines of Usage: grep [OPTION]... PATTERN [FILE]... Try `grep --help' for more information.
But when place outside the for loop, i do not get such error. Is there something wrong with my loop that is interfering with grep?
grep fmpeg- it will findffmpegtoo$finside double quotes so you can process files with spaces in their names, thus"$f"