 if exist out.mp4 del out.mp4
 if exist tmp_in_amr.amr del tmp_in_amr.amr
 if exist tmp_in_h264.cmp del tmp_in_h264.cmp
 if exist out_track1.cmp del out_track1.cmp
 rem generate AVS file
 echo LoadModule("avslib", "filters", "resize") > concatenate.avs 
 echo clip = import("%videos%") >> concatenate.avs 
 echo bc=BlankClip(1,width=320, height=240, fps=15, color=$FFFFFF) >> concatenate.avs
 echo c1 = clip.ResizeToTarget(bc) >> concatenate.avs 
 echo return c1 >> concatenate.avs
 
 
 REM Percentage 97%
 ffmpeg.exe -i concatenate.avs -r 15 -b 384k -vcodec mpeg4 -mbd rd -flags +4mv+aic -trellis 2 -cmp 2 -subcmp 2 -an out.mp4 
 Yamb\MP4Box.exe -raw 1 out.mp4 
 ffmpeg.exe -i concatenate.avs -ar 8000 -ac 1 -ab 12.2k tmp_in_amr.amr 
 M4VEncDecrypt.exe -e out_track1.cmp tmp_in_h264.cmp 320 240 "mm%input%_%mycrf%.txt"
 
 REM Percentage 98%
 MbMapCompress.exe -e "mm%input%_%mycrf%.txt" map.bin stco.bin stsz.bin 320 240 0 %nver%
 copy /b stco.bin+stsz.bin+map.bin "%input%_%mycrf%.bin"
 
 REM Percentage 99%
 echo "Handle EncDecrpt"
 call_mp4box.exe Yamb\MP4Box.exe tmp_in_h264.cmp tmp_in_amr.amr tmp_out.mp4 "%input_meta%" 
 AtomicParsley.exe tmp_out.mp4 --meta-uuid "km4v" file "%input%_%mycrf%.bin" 
 del tmp_out.mp4
 
 move /Y tmp_out-temp*.* "%input%_crf_%mycrf%_amr.mp4"
 copy /b "%input%_crf_%mycrf%_amr.mp4"+fake.fst "%input%_crf_%mycrf%_amr_e_kmv.kmv" 
 ren "%input%_crf_%mycrf%_amr_e_kmv.kmv" "%outfnm%.kmv"
  
 move /Y "%outfnm%.kmv" "%out_folder%"
 del "en_%input%_crf_%mycrf%.avs"
 del *.bin 
 del *.amr
 del *.h264 
 del "%input%_crf_%mycrf%_amr.mp4"
 del tmp.mp4
 del concatenate.avs
 del "mm%input%_%mycrf%.txt"
 del out_track1.cmp
 del tmp_in_h264.cmp
 del out.mp4
 del map.bin
 del stco.bin
 del stsz.bin 

