   function framedemo(szFile,newFile,interval,thre)
  
   pfi = OpenAviFile(szFile);
   thre = 20;
   interval =3;
   if pfi <> []
  	 new_ppavi = CreateAviFile(newFile, pfi(2), pfi(3), pfi(4), pfi(7), pfi(8));
        disp("waiting for writing.....");
        if new_ppavi <> []
   	 	for i=0:(pfi(2)-1)
       		data=AviReadFrame(pfi, i);
                     data = framesub(data, interval,thre);
			AviWriteFrame(new_ppavi, data);
			data=[];
			new_ppavi(6)=new_ppavi(6)+1;
   		end
              AviWriteEnd(new_ppavi);
        end 	
   	 AviReadEnd(pfi);
   end