static function video_consolidator($file, $new_width, $new_height) { $ffmpeg = new ffmpeg_wrapper(); $ffmpeg->add_input($file); $ffmpeg->video->qscale(0); // initialize flags $info = ffmpeg_wrapper::video_stream_info($file); $input_width = intval($info["width"]); $input_heigth = intval($info["height"]); $aspect_ratio = round(floatval($input_width / $input_heigth), 3); $new_aspect_ratio = round(floatval($new_width / $new_height), 3); /** * fix letterbox videos */ $ffmpeg->fix_letterbox($file, $new_width, $new_height); /** * convert vertical videos */ $ffmpeg->fix_vertical($file); /** * check if padding is needed */ $ffmpeg->fix_aspect_ratio_normal($aspect_ratio, $new_aspect_ratio); /** * scale to new given sizes */ if ($input_width != $new_width || $input_heigth != $new_height) { if (FFMPEG_WRAPPER_DEBUG_PRINTS) { echo ">> scale needed" . PHP_EOL; } $ffmpeg->video_filter->scale($new_width, $new_height); } else { if (FFMPEG_WRAPPER_DEBUG_PRINTS) { echo ">> no scale needed" . PHP_EOL; } } return $ffmpeg; }
public function fix_vertical($file) { $transpose_degree = ffmpeg_wrapper::analyze_rotation($file); if ($this->video_filter->transpose($transpose_degree)) { if (FFMPEG_WRAPPER_DEBUG_PRINTS) { echo ">> transpose needed" . PHP_EOL; } } else { if (FFMPEG_WRAPPER_DEBUG_PRINTS) { echo ">> no transpose needed" . PHP_EOL; } } }