Php-ffmpeg: get current video width and height

Created on 13 Aug 2014  路  5Comments  路  Source: PHP-FFMpeg/PHP-FFMpeg

how can i get current size of video height and width !? I cant find any useful method

Most helpful comment

$ffprobe = FFMpeg\FFProbe::create();
$dimension = $ffprobe
    ->streams('/path/to/video/mp4') // extracts streams informations
    ->videos()                      // filters video streams
    ->first()                       // returns the first video stream
    ->getDimensions();              // returns a FFMpeg\Coordinate\Dimension object

All 5 comments

$ffprobe = FFMpeg\FFProbe::create();
$dimension = $ffprobe
    ->streams('/path/to/video/mp4') // extracts streams informations
    ->videos()                      // filters video streams
    ->first()                       // returns the first video stream
    ->getDimensions();              // returns a FFMpeg\Coordinate\Dimension object

This works fine but I am having trouble getting to the actual dimensions... How do I access the properties? I keep getting the error

Fatal error: Uncaught Error: Cannot access private property FFMpeg\Coordinate\Dimension::$height in /var/www/html/utilities/make_thumbnails/Assets_Insert_Setup_PHP.php:68 Stack trace: #0 /var/www/html/utilities/Assets/Assets_Insert.php(1): require() #1 {main} thrown in /var/www/html/utilities/make_thumbnails/Assets_Insert_Setup_PHP.php on line 68

I tried something like below and then wanted to send the value to my own array.
$height = $dimension->height;

@totomtornado Use $dimension->getWidth() and $dimension->getHeight().

On videos where the height > width, it's swapping the width and height values for some reason? Anyone else come across this?

Do you apply the RotateFilter? https://github.com/PHP-FFMpeg/PHP-FFMpeg/blob/f9cc3d0c429fade5a144db674272eb8b48db8dce/src/FFMpeg/Filters/Video/RotateFilter.php#L57-L65
If not, please file a new issue and provide a file to reproduce with. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mdolnik picture mdolnik  路  4Comments

jankal picture jankal  路  9Comments

Mahdi-Mohammadi picture Mahdi-Mohammadi  路  4Comments

aminyazdanpanah picture aminyazdanpanah  路  6Comments

h3242749 picture h3242749  路  5Comments