8

I try to reduce the dimensions of video:

ffmpeg -i input.mp4 -y -acodec aac -ac 2 -ab 160k -vcodec libx264 -vf "scale=-1:'min(720,ih)'" -f mp4 output.mp4

I got :

width not divisible by 2 (405x720)

I tried with:

 -vf "scale=-1:'min(720,ceil(ih/2)*2)'"

Go the same because I need to keep width propotions

Any idea ?

I already read that without success:

FFMPEG (libx264) "height not divisible by 2"

yarek
  • 11,278
  • 30
  • 120
  • 219

2 Answers2

9

Use

scale='bitand(oh*dar,65534)':'min(720,ih)'

This will rescale the width proportional to the output height and then reduce it an even value.

Gyan
  • 85,394
  • 9
  • 169
  • 201
  • 4
    Can you please explain what `65534` is? My current command for scaling is `scale=999:trunc(ow/a/2)*2,overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2` – ClassA Jul 17 '20 at 14:12
  • 1
    I have asked a question, can you please have a look - https://stackoverflow.com/questions/62955932/ffmpeg-width-not-divisible-by-2 – ClassA Jul 17 '20 at 14:19
3

Use "scale=-2:'min(720,ih)'"

In general you can put -N to force it to be a multiple of N when keeping the aspect ratio, so if you were using a codec that required widths to be a multiple of 16, you could use -16 for the width.

Jason
  • 1,059
  • 9
  • 13