FFmpeg - 将最大视频尺寸调整为 320 [英] FFmpeg - Resize Largest Video Dimension to 320
问题描述
我正在尝试使用 FFmpeg 动态更改通过 PHP 上传到服务器的视频的分辨率.IE,我想保留纵向或横向 - 如果 Y 高于 X,我想将 Y 更改为 320,并将 X 更改为相应的值,反之亦然.我在调整大小本身时没有遇到问题 - 实际上非常简单.我遇到的问题是检测哪个维度更大.
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.
我从 StackOverflow 上获取了这个解决方案:如何使用 ffmpeg php 检查视频是横向还是纵向?
I grabbed this solution off StackOverflow: how to check if video is landscape or portrait using ffmpeg php?
但是,它似乎不起作用.虽然我在追踪什么不起作用 - 我假设输出的格式化方式自该解决方案发布以来已经改变,现在需要以不同的方式解析 - 我想问是否有更好的方法来做到这一点.我愿意使用 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.
推荐答案
仅供参考,正确的方法是使用FFmpeg自带的FFprobe.
FYI, the correct way to do this is to use FFprobe, which comes with FFmpeg.
https://www.ffmpeg.org/ffprobe.html
这篇关于FFmpeg - 将最大视频尺寸调整为 320的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!