We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When doing a vertical video conversion, the resize filter stretches the video
Applying the resize filter should keep into consideration the input video rotation
require 'vendor/autoload.php'; $ffmpeg = FFMpeg\FFMpeg::create(); $video = $ffmpeg->open('video.mov'); $video->filters() ->resize( new FFMpeg\Coordinate\Dimension(320, 180), FFMpeg\Filters\Video\ResizeFilter::RESIZEMODE_INSET ) ->synchronize(); $video ->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(10)) ->save('frame.jpg'); // stretched $video ->save(new FFMpeg\Format\Video\X264(), 'export-x264.mp4'); // stretched
example taken from here
I actually tried this and works for my use case, maybe we may change the ResizeFilter accordingly ? (I may work on a PR if this works for you)
- $commands[] = '[in]scale=' . $dimensions->getWidth() . ':' . $dimensions->getHeight() . ' [out]'; + $commands[] = "[in]scale=w='if(gt(iw\,ih),{$dimensions->getWidth()},{$dimensions->getHeight()})':h='if(gt(iw\,ih),{$dimensions->getHeight()},{$dimensions->getWidth()})'[out]";
By checking the input width/height before applying the resize filter, the output video has a good format/orientation.
Maybe the ResizeFilter may introduce a default parameter to "handle auto detect of input orientation"
- public function __construct(Dimension $dimension, $mode = self::RESIZEMODE_FIT, $forceStandards = true, $priority = 0) + public function __construct(Dimension $dimension, $mode = self::RESIZEMODE_FIT, $forceStandards = true, $priority = 0, $guessOrientation = false) ... + if ($this->guessOrientation) { + $commands[] = "[in]scale=w='if(gt(iw\,ih),{$dimensions->getWidth()},{$dimensions->getHeight()})':h='if(gt(iw\,ih),{$dimensions->getHeight()},{$dimensions->getWidth()})'[out]"; + } else { $commands[] = '[in]scale=' . $dimensions->getWidth() . ':' . $dimensions->getHeight() . ' [out]'; + }
The text was updated successfully, but these errors were encountered:
I noticed the same issue. Had a 1080x1920 vertical video from an iPhone (according to the meta data it has a 90° rotation) and when using
$video ->filters() ->resize(new Dimension(1920, 1080), ResizeFilter::RESIZEMODE_INSET, false) ->synchronize() ;
the video will end up being a 1920x1080 stretched video, instead of 607x1080 (which I would have expected at least).
Sorry, something went wrong.
Using this solution solves the issue for me: #177 (comment)
No branches or pull requests
Actual Behavior
When doing a vertical video conversion, the resize filter stretches the video
Expected Behavior
Applying the resize filter should keep into consideration the input video rotation
Steps to Reproduce
example taken from here
Possible Solutions
I actually tried this and works for my use case, maybe we may change the ResizeFilter accordingly ? (I may work on a PR if this works for you)
By checking the input width/height before applying the resize filter, the output video has a good format/orientation.
Maybe the ResizeFilter may introduce a default parameter to "handle auto detect of input orientation"
The text was updated successfully, but these errors were encountered: