REMOVE INITIAL AND ENDING HTML TAGS AND RUN FROM COMMAND LINE AS "php splitinto10.php" after entering the name of the files you want to split into 10 minutes parts. This requires the mplayer program "mencoder".
place the below code inbetween php tags.
//split into 10 minute videos
//need length or simply try until mencoder fails?
//endpos is a time added to ss
//split video into 10 minute parts
//mencoder -ss 01:00:00 -endpos 09:59 -oac copy -ovc copy movie.avi -o second_half.avi
$nosplit=0; ///to do a direct conversion of some video without splitting
//$ipth='/home/charach2nd/';
$ipth='/root/web/';
$file='vlog20090420-194916.flv';
//$file='vlog20090305-225316.flv';
$outpath=$ipth;
$outf=substr($file,0,strlen($file)-4);
$exten=substr($file,strlen($file)-4,4);
//$exten=".avi"; //format will be flv
if ($nosplit) {
//original
//mjpeg
// $s1='/usr/bin/mencoder '.$ipth.$file.' -of lavf -ovc lavc -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=500:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -noskip -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -o '.$outpath.$outf.'_flv'.$exten;
$s1='/usr/bin/mencoder '.$ipth.$file.' -of lavf -ovc lavc -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=500:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -noskip -o '.$outpath.$outf.'_flv'.$exten;
// $s1='/usr/bin/mencoder '.$ipth.$file.' -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=500 -vop scale=360:240 -oac mp3lame -lameopts abr:br=56 -o '.$outpath.$outf.'_360x240'.$exten;
echo $s1.chr(10);
$lastline=exec($s1,$retval);
// $s1='/usr/bin/mencoder '.$ipth.$file.' -dvd 2 -of lavc -lavcopts vcodec=mpeg4:vpass=2 -oac copy -o '.$outpath.$outf.'_flv'.$exten;
// echo $s1.chr(10);
$lastline=exec($s1,$retval);
} else { //not $nosplit
$stime=0;
$ntime=0;
$count=1;
//can do a mplayer -identify -frames 0 filename.avi 2>&1 | grep ID_LENGTH
//to get length in seconds
$tstr='mplayer -identify -frames 0 '.$ipth.$file.' 2>&1 | grep ID_LENGTH';
// $lenga=split("=",exec($tstr,$retval));
$lenga=split("=",system($tstr,$retval));
$leng=$lenga[1];
$ntime=0;//$leng;
$numvid=intval($leng/599);
if ($leng%599) { $numvid++; }
while($ntime<$leng) {
//no scale for now
$outfile=sprintf("%s_%02d_of_%02d%s",$outf,$count,$numvid,$exten);
if ($leng-$ntime>599) {
$dur=599;
} else {
$dur=$leng-$ntime;
}
// $s1='/usr/bin/mencoder '.$ipth.$file.' -ss '.$ntime.' -endpos '.$dur.' -of lavf -ovc lavc -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=500:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -noskip -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -o '.$outpath.$outfile;
$s1='/usr/bin/mencoder '.$ipth.$file.' -ss '.$ntime.' -endpos '.$dur.' -of lavf -ovc lavc -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=500:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -noskip -o '.$outpath.$outfile;
// $s1='/usr/bin/mencoder '.$ipth.$file.' -ss '.$ntime.' -endpos '.$dur.' -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=500 -vop scale=360:240 -oac mp3lame -lameopts abr:br=56 -o '.$outpath.$outfile;
$ntime+=$dur;
//dont need to divide into hh:mm:ss
/*
//presumes no video>24 hours
//hours
if ($ntime>3600) {
sprintf($stime,"%s",intval($ntime/3600));
$ntime-=intval($ntime/3600);
}
//minutes
if ($ntime>60) {
sprintf($stime,"%s:%s",$stime,intval($ntime/60));
$ntime-=intval($ntime/60);
}
//seconds
sprintf($stime,"%s:%s",$stime,intval($ntime/60));
*/
echo $s1.chr(10);
$count++;
$lastline=exec($s1,$retval);
} //while
} //nosplit