Search code examples
ffmpeg

Using if statement in ffmpeg


is it possible using if/else statement in ffmpeg ?

I would want to tell ffmpeg if dimension of any video lower than 480p do not touch the height or width otherwise do encode and resize it to 480p, here's my command but it always scale up the video if the video lower than 480p

ffmpeg -i input.mp4 -c:v libx264 -crf 31 -me_method umh -bf 0 -vf scale=480:-2 out.mp4

Note that i dont want to use any programming language because it's on windows cmd.


Solution

  • The notation 480p refers to the height, so I assume that's what you mean.

    Use

    ffmpeg -i input.mp4 -c:v libx264 -crf 31 -me_method umh -bf 0 -vf scale='if(gte(ih\,480)\,480\,iw)':-2 out.mp4

    This will rescale videos whose height is 480 or more.