Merge branch 'fix-aspect-ratio' of github.com:nlegoff/PHP-FFmpeg into nlegoff-fix-aspect-ratio

* 'fix-aspect-ratio' of github.com:nlegoff/PHP-FFmpeg:
  Fix video aspect ratio calculation
This commit is contained in:
Romain Neutron 2014-08-26 10:45:33 +02:00
commit f2a6329829
2 changed files with 44 additions and 10 deletions

View file

@ -72,7 +72,12 @@ class Stream extends AbstractData
if (null !== $displayRatio && null !== $sampleRatio) {
if ($sampleRatio[0] !== 1 && $sampleRatio[1] !== 1) {
$width = round($width / $sampleRatio[0] * $sampleRatio[1] * $displayRatio[0] / $displayRatio[1]);
if (null !== $width && null !== $height) {
// stretch video according to pixel sample aspect ratio
$width = round($width * ($sampleRatio[0] / $sampleRatio[1]));
// set height according to display aspect ratio
$height = round($width * ($displayRatio[1] / $displayRatio[0]));
}
}
}