ffmpeg

FFMEG option scale=-1 and scale=-2


I tried to convert a video and resize it with scale=-1:720, but got the error "width not divisible by 2". And I solved it with: scale=-2:720. What are the differences between

scale=-1:720

and

scale=-2:720

Solution

  • Use -2 instead of -1 if you want the error message to go away. It will automatically adjust the -2 dimension to be divisible by 2.

    The reason why you get the error msg is because ffmpeg is attempting to retain the original video aspect ratio. When it cannot, it lets you decided how to best to continue. For example, lets say you have a input video of 1080x1920 and you use the command -vf scale=-1:360 to resizing it to a height of 360, and the output width to 202.5 pixels - obviously the width isn't divisible by 2. By using -2 it instructs ffmpeg #if need be# to automatically adjust the -2 dimension. In the case above, it will round the width down to 202 pixels, how-ever keep in mind the output will not have the same aspect ratio as the original.

    Even though the error message is annoying I do believe it is the correct thing to do. Report a error to the user and let them choose the best course of action.