56 lines
1.4 KiB
PHP
56 lines
1.4 KiB
PHP
<?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);
|
|
$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);
|
|
}
|
|
return $script;
|
|
}
|
|
|
|
}
|
|
|
|
return new ExecutorPlugin();
|
|
|