PHP-FFMPEG is an Object-Oriented library to convert video/audio files with FFmpeg / AVConv, it makes working with FFmpeg a lot easier.
How to Fix Width Not Divisible By 2 Error When Using FFmpeg
If you get the following error message when encoding video using FFMPEG, you are in luck. We will show you how to fix this error in this tutorial.
[libx264] width not divisible by 2
This error message is very simple, width has to be divisible by 2. All you need to do is check if the width is divisible by 2, if it is not, increase it by 1. See below PHP code sample:
if ($width % 2 != 0) {
$width++;
}
Height Not Divisible By 2 Error
The solution is the same for height not divisible by 2:
if ($height % 2 != 0) {
$height++;
}
This is everything you need to do to fix width not divisible by 2 or height not divisible by 2 when using FFmpeg.