Skip to content

Instantly share code, notes, and snippets.

@rrdial
Created June 24, 2013 19:22
Show Gist options
  • Save rrdial/5852730 to your computer and use it in GitHub Desktop.
Save rrdial/5852730 to your computer and use it in GitHub Desktop.
Very simple script to avconvert an entire folder of videos assuming they have an mp4, m4v, mov extension.
#!/usr/bin/env php
<?php
$raw_videos = __DIR__ . '/raw/';
$converted_videos = __DIR__ . '/converted/';
if (file_exists($raw_videos) and is_dir($raw_videos))
{
if (!file_exists($converted_videos))
{
mkdir($converted_videos);
}
foreach (glob($raw_videos . '/*.m*') as $file)
{
echo PHP_EOL, '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>', PHP_EOL, '---> Conversion started for ', basename($file), PHP_EOL;
$output = $converted_videos . basename($file);
shell_exec('/usr/bin/avconvert -q -prog --preset Preset1920x1080 --source ' . escapeshellarg($file) . ' --output ' . escapeshellarg($output));
echo '---> Conversion completed for ', basename($file), PHP_EOL, '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>', PHP_EOL;
}
}
else
{
echo PHP_EOL, '<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>';
echo PHP_EOL, '---->> Raw folder does not exist!';
echo PHP_EOL, '<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>', PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment