I'm trying to cut a video into 2-minute clips using FFMpeg. I am using Ubuntu 10.10.
Here is my code:
#!/bin/sh
COUNTER=0
BEG=0
MIN=`ffmpeg -i ${1} 2>&1 | grep "Duration" | cut -d ' ' -f 4 | sed s/,// | cut -d ":" -f 2`
echo $MIN
((MIN=MIN-2))
before_last_dot=${1%.*};
while [ $COUNTER -lt $MIN ]; do
((BEG=COUNTER*60))
echo "MIN:${MIN}"
echo "ffmpeg -sameq -i ${1} -ss ${BEG} -t 120 ${before_last_dot}.${COUNTER}.wmv"
((COUNTER=COUNTER+2))
done
echo "ffmpeg -sameq -i ${1} -ss ${BEG} -t 120 ${before_last_dot}.${COUNTER}.wmv"
should be ffmpeg -sameq -i ${1} -ss ${BEG} -t 120 ${before_last_dot}.${COUNTER}.wmv
. I print it to check it. ${1} is the video name.
But the problem is, ((COUNTER=COUNTER+2))
or ((COUNTER+=2))
never works! COUNTER
is always 0, BEG
is always 0 too. ((MIN=MIN-2))
never works too.
I tried to replace ((MIN=MIN-2))
with let "MIN-=2"
I get an error: let: not found
I+ve double checked but still don't know why. I'm getting gray hair on this.