Get native video resolution of a video file

前提是你 提交于 2019-12-08 06:33:35

问题


I'm currently writing some custom EVR for a Media Foundation player.

So far everything work, but i'm in need of finding the native resolution of the video file i'm rendering.

I try to use the IBasicFilter2 Interface to use the getVideoSize, get_VideoHeight or other get_SourceWidth etc... but it always return me a E_NOINTERFACE...

So do someone have an esay way of getting resolution of a video file? Even if it's with a nice light library...just the size nothing else...Windows manage to find it inside the file browser, but i'm totally unable to get it from code...

Thanks!


回答1:


You can use IMediaDet in DirectShow to get information on the streams in a media file including the resolution of video streams.

There are come caveats though so you might want a backup method.

You need suitable DirectShow filters registered which understand the media file being examined. It's possible that you may have a filter installed that gives wrong results - e.g. an audio only filter is registered for a media type that ignores any video streams in the file.

It's currently deprecated with no indication on the MSDN reference page of what is replacing this functionality. It can also be a pain to build as the headers have been removed from the Windows SDK.

Here's one case in point where that method doesn't work... Get MP4 stream lengths



来源:https://stackoverflow.com/questions/5145730/get-native-video-resolution-of-a-video-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!