<?php
function file_list($d,$x){
  foreach(array_diff(scandir($d),array('.','..')) as $f)if(is_file($d.'/'.$f)&&(($x)?preg_match("/".$x.'$/',$f):1))$l[]=$f;
  return $l;
}
foreach(file_list("./",".mp4") as $mp4) {
  $aac = substr($mp4, 0, -4) . '.aac';
  $aac2 = substr($mp4, 0, -4) . '2.aac';
  if (!file_exists($aac)) exec ("ffmpeg -i \"$mp4\" -vn -acodec  copy \"$aac\"");
  if (!file_exists($aac2)) exec ("ffmpeg -i \"$mp4\" -af silenceremove=1:0:-50dB \"$aac2\"");
}