Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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.

I'm running ffmpeg code in windows cmd alone, im not using any other programming language (i updated my question) – Diok May 2, 2019 at 10:40

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.

thanks do you test it by your self? because it causes error in my side : [Parsed_scale_0 @ 000001deab116e80] Invalid size 'if(gte(ih' [AVFilterGraph @ 000001deab4eac00] Error initializing filter 'scale' with args 'if(gte(ih:flags=bicubic' Error reinitializing filters! Failed to inject frame into filter network: Invalid argument Error while processing the decoded data for stream #0:0 Conversion failed! – Diok May 2, 2019 at 10:46

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.