php-vfxapply/plugins/executor/plugin.php

56 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2016-12-25 16:49:43 +00:00
<?php
namespace VfxApply\Plugin\Executor;
use VfxApply\Plugin;
use VfxApply\Input;
use VfxApply\Output;
use VfxApply\Preset;
class ExecutorPlugin extends Plugin
{
public function getName()
{
return "executor";
}
public function applyPreset(Preset $preset, Input $input, Output $output)
{
$env = [
'uinput' => $input->getFilename(),
'uoutput' => $output->getFilename(),
'frames' => $input->getVideoDuration()->frames,
'seconds' => $input->getVideoDuration()->seconds,
];
$env['input'] = escapeshellarg($env['uinput']);
$env['output'] = escapeshellarg($env['uoutput']);
$script = $this->loadScript($preset);
$script->setPlugin($this);
2016-12-25 16:49:43 +00:00
$script->execute($env);
}
private function loadScript(Preset $preset)
{
$script = new Script();
foreach ((array)$preset->get('set') as $k=>$v) {
$script->set($k,$v);
}
foreach ((array)$preset->get('script') as $name=>$step) {
$op = new Operation($name, $step);
$script->addOperation($op);
}
foreach ((array)$preset->get('helpers') as $name=>$helper) {
$hs = new Helper($helper);
$script->addHelper($name, $hs);
2016-12-25 16:49:43 +00:00
}
return $script;
2016-12-25 16:49:43 +00:00
}
}
return new ExecutorPlugin();