0

so i have a little problem with my current ffmpeg script. I'm trying to keep the video in its original resolution if its not over 1280×720. But anything that is above 1280×720, down-scale/resize it to 1280×720.

Currently i have the below filter:

-filter:v "scale='min(1280,iw)':min'(720,ih)':force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2"

However, this by the looks of it changes all videos to 1280×720, which then causes black bars on videos that are for example recorded on phone etc...

Example:

If 1920x1080 > downscale to 1280×720

If anything above 1280×720 > downscale to 1280×720

If 1280×720 > Keep it

If anything below 1280×720 > Keep the original resolution

Hope anyone could help me with this. Thank you.

2
  • remove ,pad=... or change pad=... part to pad='min(1280,iw)':'min(720,iw/16*9)':(ow-iw)/2:(oh-ih)/2 or pad='min(1280,iw)':'min(720,ih)':(ow-iw)/2:(oh-ih)/2 Dec 9, 2020 at 6:35
  • @БаярГончикжапов i can't thank you enough. You dont know how much you have helped me. Removing ,pad=... worked. Dec 22, 2020 at 11:29

1 Answer 1

0

You could use mediainfo to check the height/width. To check if height is greater-than/equal to:

(( $(mediainfo --Output='Video;%Height%' Big_Buck_Bunny_1080p_surround.mp4) >= 720 )) && echo "greater or equal to 720" || echo "less than 720"

To check if height is less than:

(( $(mediainfo --Output='Video;%Height%' Big_Buck_Bunny_1080p_surround.mp4) < 720 )) && echo "less than 720" || echo "greater than 720"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .