Search code examples
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 message when you use -1 is because you're telling ffmpeg to keep the same aspect ratio as the original. When it cannot it returns with the error message "not divisible by 2". 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, you will end up with a width of 202.5 pixels. That is why you're getting the error message "width not divisible by 2".

    How-ever by using -2 it tells ffmpeg (!if need be!) to adjust the -2 dimension to be divisible by 2. In the case above, it will round the width down to 202 pixels but the output will have a slightly different aspect ratio to 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.