Skip to content
Advertisement

FFmpeg – Resize Largest Video Dimension to 320

I’m trying to dynamically change the resolution of videos uploaded to a server via PHP, using FFmpeg. IE, I want to preserve portrait or landscape orientation – if Y is higher than X, I want to change Y to 320 and X to a corresponding value, and vice versa. I’m not having trouble with the resizing itself – it’s quite straightforward, actually. What I’m having trouble with is detecting which dimension is larger.

I grabbed this solution off StackOverflow: how to check if video is landscape or portrait using ffmpeg php?

However, it doesn’t appear to be working. While I track down what isn’t working – I’m assuming the way the output is formatted has changed since that solution was posted, and it now needs to be parsed differently – I wanted to ask if there was a better way to do this. I’m open to using FFmpeg or a PHP-based solution.

Advertisement

Answer

FYI, the correct way to do this is to use FFprobe, which comes with FFmpeg.

https://www.ffmpeg.org/ffprobe.html

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement