Skip to content

Commit

Permalink
Merge branch '0.4'
Browse files Browse the repository at this point in the history
* 0.4:
  Update CHANGELOG
  Fix width & height video extraction to take aspect ratio into account

Conflicts:
	CHANGELOG.md
  • Loading branch information
romainneutron committed Aug 26, 2014
2 parents 71d98ea + f365fe2 commit e543cff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,10 @@
CHANGELOG
---------

* 0.4.4 (08-26-2014)

* Fix width and height video extraction (@nlegoff).

* 0.4.3 (01-06-2014)

* Fix video audio sample rate cast.
Expand Down
26 changes: 10 additions & 16 deletions src/MediaVorus/Media/Video.php
Expand Up @@ -45,27 +45,24 @@ public function getType()
*/
public function getWidth()
{
if (null !== $result = parent::getWidth()) {
return $result;
}
$width = parent::getWidth();

if (null === $this->ffprobe) {
return null;
return $width;
}

try {
$video = $this->ffprobe
->streams($this->file->getPathname())
->videos()
->first();
if ($video->has('width')) {
return (int) $video->get('width');
}

return $video->getDimensions()->getWidth();
} catch (FFMpegException $e) {

}

return null;
return $width;
}

/**
Expand All @@ -75,27 +72,24 @@ public function getWidth()
*/
public function getHeight()
{
if (null !== $result = parent::getHeight()) {
return $result;
}
$height = parent::getHeight();

if (null === $this->ffprobe) {
return null;
return $height;
}

try {
$video = $this->ffprobe
->streams($this->file->getPathname())
->videos()
->first();
if ($video->has('height')) {
return (int) $video->get('height');
}

return $video->getDimensions()->getHeight();
} catch (FFMpegException $e) {

}

return null;
return $height;
}

/**
Expand Down

0 comments on commit e543cff

Please sign in to comment.