Example #1
0
 public function handle()
 {
     $job = PasoJob::commonInit($this->project, 'rendering');
     /*
     	melt writes progresses on stderr, so I have to open a pipe on that channel.
     	A simple popen() opens only stdout
     */
     $command = sprintf('%s %s/config.mlt -consumer avformat:%s/output.%s %s -progress', Conf::read('melt_path'), $this->project->folder(), $this->project->folder(), $this->project->extension, $this->project->render_string);
     $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
     $process = proc_open($command, $descriptorspec, $pipes);
     if (is_resource($process)) {
         while (!feof($pipes[2])) {
             $buffer = fread($pipes[2], 500);
             preg_match('/percentage: *([0-9]{1,2})/', $buffer, $matches);
             if (count($matches) == 2) {
                 $job->percentage = $matches[1];
                 $job->save();
             }
             /*
             	TODO: intercept errors from melt
             */
         }
     }
     $job->percentage = 100;
     $job->save();
     $this->project = $this->project->fresh();
     if ($this->project->status != 'failed') {
         $this->project->status = 'ready';
         $this->project->save();
     }
 }
Example #2
0
 public static function getKdenliveProfiles()
 {
     $ret = [];
     $file = Conf::read('kdenlive_profiles_file');
     if (file_exists($file) == false) {
         return $ret;
     }
     $cfile = file_get_contents($file);
     $xml = new \SimpleXMLElement($cfile);
     $groups = $xml->xpath('//group');
     foreach ($groups as $group) {
         $g = (object) array();
         $g->name = $group->attributes()['name'];
         $g->slug = str_slug($g->name);
         $parent_extension = $group->attributes()['extension'];
         $g->profiles = [];
         $profiles = $group->xpath('profile');
         foreach ($profiles as $profile) {
             $attrs = $profile->attributes();
             $p = (object) array();
             $p->name = $attrs['name'];
             $p->slug = str_slug($p->name);
             $p->args = $attrs['args'];
             $p->haspass = strpos($p->args, '%passes') != false;
             if ($attrs['bitrates'] != null) {
                 $p->bitrates = explode(',', $attrs['bitrates']);
             } else {
                 if ($attrs['qualities'] != null) {
                     $p->bitrates = explode(',', $attrs['qualities']);
                 } else {
                     $p->bitrates = array();
                 }
             }
             if ($attrs['audiobitrates'] != null) {
                 $p->audiobitrates = explode(',', $attrs['audiobitrates']);
             } else {
                 if ($attrs['audioqualities'] != null) {
                     $p->audiobitrates = explode(',', $attrs['audioqualities']);
                 } else {
                     $p->audiobitrates = array();
                 }
             }
             if ($attrs['extension'] != null) {
                 $p->extension = $attrs['extension'];
             } else {
                 $p->extension = $parent_extension;
             }
             $g->profiles[] = $p;
         }
         $ret[] = $g;
     }
     return $ret;
 }
 public function index()
 {
     $data['projects'] = Project::orderBy('created_at', 'desc')->get();
     $data['kdenlive_profiles'] = Conf::getKdenliveProfiles();
     $confs = array();
     $dbconfs = Conf::get();
     foreach ($dbconfs as $c) {
         $confs[$c->name] = $c->value;
     }
     $data['confs'] = $confs;
     return view('homepage', $data);
 }
 private function saveConf($request, $name)
 {
     $conf = Conf::where('name', '=', $name)->firstOrFail();
     $conf->value = $request->input($name);
     $conf->save();
 }