Qt:读取视频尺寸而不创建视频播放器
我需要读取给定视频文件的尺寸(其宽度和高度),而不构建视频播放器,例如 Phonon,例如我的问题是我应该使用哪个类来访问此数据。我已经尝试过使用 QPixmap 和 QMovie,但它们都不支持 *.mov。
谢谢你!
I need to read the dimensions of a given video file (its width and height), without constructing a video player, like Phonon, e.g. My question is which class I should use to get access to this data. I have already tried using QPixmap and QMovie, but niether of them supports *.mov.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Pavlo,你可以试试这个:
代码使用 QMediaResource来自 Qt Mobility 项目的类。我还没有尝试过,我想你至少需要一个正确的后端(能够读取 MOV 格式的插件)。我仅根据 API 概述给出这个答案。
希望这有帮助。
Pavlo, you can try this:
The code uses QMediaResource class from Qt Mobility project. I haven't tried it yet and I suppose you need at least a correct backend (plugin that is capable of reading MOV format). I'm giving this answer only from API overview.
Hope this helps.
我终于解决了我的问题,我想我会与其他人分享我的解决方案。
在类构造函数中,我初始化以下两个变量:
我将
media
信号连接到类中的插槽:我让用户选择一个视频文件:
并将该文件应用于
media
对象:由于
media
对象已连接到插槽,因此可以在其帮助下监视media
中的每个变化。然而,我必须承认,这段代码在我看来相当慢。声子库仅在我的程序中使用在一个地方,就是在这里,在一个对话框窗口中,用户可以选择要嵌入的视频剪辑,我希望从文件中读取视频尺寸。这个对话框窗口打开需要一些时间,所以我想,这个解决方案对于我的问题来说有点太苛刻了。但是,我无法找到其他解决方案。如果对这篇文章的主题有不同的意见,我很高兴听到他们的意见。
I finally solved my problem and I thought I'd share my solution with everybody else.
In the class constructor I initialize the following two variables:
I connect a signal of
media
to a slot in my class:I let the user choose a video file:
And apply this file to the
media
object:Because
media
object is already connected to a slot, every change inmedia
can be monitored with its help.I must admit, however, that this code seems to me to be quite slow. Phonon library is used in my program only in one place, and this is here, in a dialog window where user can choose a video clip to embed, and i want the video dimensions to be read from file. It takes some time until this dialog window opens, so I guess, this solution is a bit too harsh for my problem. However, I was not able to find another solution. If there are different opinions as to the subject of this post, I'd be glad to hear them.