Question

Can anybody tell me how I can return the dimensions of a video (pixel height/width) using Qt (or any other Python route to that information). I have googled the hell out of it and cannot find a straight answer.

I assumed it would either be mediaobject.metadata() or os.stat() but neither appear to return the required info.

Was it helpful?

Solution 2

OK - for others out there looking for the same info, I found Hachoir-metadata and Hachoir-parser (https://bitbucket.org/haypo/hachoir/wiki/Home).

They provide the correct info but there is a serious lack of docs for it and not that many examples that I can find. Therefore, while I have parsed a video file and returned the metadata for it, I'm now struggling to 'get' that information in a usable format. However, I will not be defeated!

OTHER TIPS

Amazingly it seems like there's no provided functionality to do that (odd omission), it just recommends calling sizeHint on a Phonon::VideoWidget if you need to get the size of the video. There is the Kaa Media libraries, which provide a height and width in the metadata package, I will say I've never used them though, but they look like they should give you the information you need.

MediaInfo is probably what you are looking for. It's an open-source media library with Python and other bindings that can get just about any media info you need, including video width and height.

I've used it more in C++ and C# than Python, but the call to get video width after opening the file would be similar to this:

mediaInfo.Get(streamKind, id, "Width")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top