static function split_screen_video($files) { $total = count($files); // @TODO: dynamic size needed $input_size = new ffmpeg_size(1280, 720); // @TODO: find/get the length of the longest movie // alternatively, use something like -shortest to 'movie=' filter $ffmpeg = ffmpeg_presets::empty_movie($input_size->to_string(), 300); // find the size of the cube if (in_array($total, range(1, 4))) { $cube = 2; } else { if (in_array($total, range(5, 9))) { $cube = 3; } else { if (in_array($total, range(10, 16))) { $cube = 4; } else { $cube = 1; } } } $output_w = $input_size->width / $cube; $output_h = $input_size->heigth / $cube; // from top to bottom, left to right $points = array(); for ($i = 0; $i < $total; $i++) { $row = floor($i / $cube); $colm = $i % $cube; $px = round($colm * $output_w); $py = round($row * $output_h); // echo $row . ":" . $colm . "\t" . $px . ":" . $py . PHP_EOL; $points[$i] = new ffmpeg_point($colm * $output_w, $row * $output_h); $ffmpeg->video_filter->overlay_with_filters($files[$i], $points[$i]->x, $points[$i]->y, ffmpeg_filter::scale($input_size->width / $cube, $input_size->heigth / $cube)); } return $ffmpeg; }
public function transpose($transpose_degree) { switch ($transpose_degree) { case 0: return false; break; case 90: case 270: $info = $this->ffmpeg_wrapper->last_input_info_video; $currnet_width = $info["width"]; $current_height = $info["height"]; $new_width = intval($current_height * ($current_height / $currnet_width)); $new_heigth = intval($current_height); $padcenter_filter = ffmpeg_filter::filter_with_params("pad", array($currnet_width, $current_height, "(ow-iw)/2", "(oh-ih)/2"), array(), array()); $scale_filter = ffmpeg_filter::filter_with_params("scale", array($new_width, $new_heigth), array(), array(), $padcenter_filter); $this->add_simple_filter_with_filter("transpose", array(1), $scale_filter); if ($transpose_degree == 270) { $this->hflip(); } return true; break; case 180: $this->hflip(); $this->vflip(); return true; break; default: return false; break; } return false; }