<p>There's no native video processing library built in PHP, so you're gonna need a third-party library for this. For example:</p>
<ul>
<li><a href="https://github.com/PHP-FFMpeg/PHP-FFMpeg" rel="nofollow noreferrer">php-ffmpeg/php-ffmpeg</a></li>
<li><a href="https://github.com/JamesHeinrich/getID3" rel="nofollow noreferrer">james-heinrich/getid3</a></li>
</ul>
<p>If you're working on a site module, just install the libraries with composer. For FFmpeg, make sure to read the installation instructions – ffmpeg needs to be installed separately from the PHP library on your server. Check the documentation to find out how to process videos and get the dimensions using these libraries.</p>
<p>To provide a gateway to PHP and/or Twig, check out the documentation on <a href="https://craftcms.com/docs/3.x/extend/module-guide.html" rel="nofollow noreferrer">how to build a module</a> and on <a href="https://craftcms.com/docs/3.x/extend/extending-twig.html" rel="nofollow noreferrer">extending Twig</a>.</p>
<p>If you're building a plugin, you're gonna want to make sure that it works in different environments. In particular for FFmpeg, make sure to provide installation instructions.</p>

CC BY-SA 4.0
2022-02-04T14:47:38.057Z
2022-02-04T14:47:38.057Z
MoritzLost
<p>I need to get the width and height of videos to calculate some aspect ratio. Craft doesn't do this out of the box. Any plugins that does this? Or can i write my own?</p>

<craft3><assets><plugins><video>
Get the width and height of videos
# Get the width and height of videos

(Asked by: username_0 on 2022-02-04)

I need to get the width and height of videos to calculate some aspect ratio. Craft doesn't do this out of the box. Any plugins that does this? Or can i write my own?

**Tags:** craft3, assets, plugins, video


---

## 1 answers

### Answer by username_1 on 2022-02-04. Score: 2

There's no native video processing library built in PHP, so you're gonna need a third-party library for this. For example:

* [php-ffmpeg/php-ffmpeg](https://github.com/PHP-FFMpeg/PHP-FFMpeg)
* [james-heinrich/getid3](https://github.com/JamesHeinrich/getID3)

If you're working on a site module, just install the libraries with composer. For FFmpeg, make sure to read the installation instructions – ffmpeg needs to be installed separately from the PHP library on your server. Check the documentation to find out how to process videos and get the dimensions using these libraries.

To provide a gateway to PHP and/or Twig, check out the documentation on [how to build a module](https://craftcms.com/docs/3.x/extend/module-guide.html) and on [extending Twig](https://craftcms.com/docs/3.x/extend/extending-twig.html).

If you're building a plugin, you're gonna want to make sure that it works in different environments. In particular for FFmpeg, make sure to provide installation instructions.


---

