Quick hack to preview an XDCAM-EX-folder

XDCAM EX folders are structures with MPEG4 files, but with an embedded MPEG2 codec, so you cannot read them directly in QuickTime Player. You can read them in the ContentBrowser by Sony, but not convert unless you buy the full program.

ffmpeg can read the files and convert the files to MPEG4 with h.264 (previews which are about 10 times smaller with the standard setting. However, the files are all hidden in folders and converting one by one is steady.

So I wrote a small php script you can put in the same folder you install ffmpeg and run in the terminal instead of running ffmpeg directly. It has one parameter: -i is the path to the CLPR folder. The MPG4 files will be exported directly into the CLPR folder.

Installation

Install ffmpeg.
Install the convertall.php script to the same folder as ffmpeg.

Usage

cd PATH-TO-FFMPEG
php convertall.php -i PATH-TO-CLPR-FOLDER

Source Code

for($i=0;$i<count($argv);$i++)
{ 
  $v = $argv[$i];
  if ($v == '-i') { $folder = $argv[$i+1]; $i++; }
}
echo $folder.PHP_EOL;
if (is_dir($folder))
{
 if ($dh = opendir($folder))
 {
  while (($file = readdir($dh)) !== false) {
  if (is_dir($folder.'/'.$file))
  {
   echo $file.PHP_EOL;
   if ($dh2 = opendir($folder.'/'.$file)) 
   {
    while (($file2 = readdir($dh2)) !== false)
    {
     if (stristr($file2,'.mp4'))
     {
      echo  '-'.$file2.PHP_EOL;
      $ex = './ffmpeg -i '.$folder.'/'.$file.'/'.$file2.' '.$folder.'/'.$file2.'.mp4';
      echo $ex.PHP_EOL;
      exec($ex);
     }
    }
   }
  }
 }
 closedir($dh);
 }

}