something like this might work... let me know if this is kind of what you are looking for.
I decided to invoke ffmpeg with seconds instead of the other syntax, as it was easier.
Code:
#!/bin/bash
video="file" # this is if the file name is actually file.avi we drop the .avi
totallen="00:52:23.02" # this is the length of the movie
minChunk=10 # set this to the minute sized chunks you want
function math
{
newNumber=`bc -l 2> /dev/null<< EOF
scale = 2
${1}
EOF
`
if [[ "$newNumber" == "" ]]
then
newNumber="bc is not installed"
fi
echo "$newNumber"
}
thour=`echo $totallen | cut -d: -f1`
tmin=`echo $totallen | cut -d: -f2`
tsec=`echo $totallen | cut -d: -f3`
shour=`math "$thour * 60 * 60"`
smin=`math "$tmin * 60"`
usedsec=`echo $tsec | cut -d. -f1`
decsec=`echo $tsec | cut -d. -f2`
ssec=`math "$shour + $smin + $usedsec"`
secChunk=`math "$minChunk * 60"`
lenleft=$ssec
strstart=0 # this is the start point in seconds
i=1
until [ $lenleft -lt $secChunk ]
do
echo "ffmpeg -i ${video}.avi -ss ${strstart} -t ${secChunk} ${video}_part_${i}.avi"
# ffmpeg -i ${video}.avi -ss ${strstart} -t ${secChunk} ${video}_part_${i}.avi
lenleft=`math "$lenleft - $secChunk"`
strstart=`math "$strstart + $secChunk"`
((i++))
echo "${i}|${lenleft}|${strstart}"
done
strstart=`math "$strstart + .$decsec"`
echo "ffmpeg -i ${video}.avi -ss ${strstart} ${video}_part_${i}.avi"
# ffmpeg -i ${video}.avi -ss ${strstart} ${video}_part_${i}.avi
comment out the echo "ffmpeg..." and remove the comment from the ffmpeg command itself under to make it actually run and not just display the command that it would run.
Edit: I had to make changes after the loop... the way the code was, it would have tried to make the last clip wrong. I removed the -t option for the last clip as well, because it shouldn't need it, if you tell it when to start, it should just go to the end.