Programmatically get video duration

爷,独闯天下 提交于 2019-12-24 08:37:19

问题


I'd need to get the video duration of a mp4 video (video format AVC)

I'm using DirectShowLib 2.1

I downloaded a couple of codecs but I'm still getting code -2147220891 (an error code that I don't know what it means) doing

 graphBuilder.RenderFile(filePath, null);

Any idea how to get the duration of this kind of video?


回答1:


-2147220891 is 0x80040265 in hex. A search for that error code revealed this thread

0x80040265 isn't really "unknown". Strictly, it is VFW_E_UNSUPPORTED_STREAM, which means that your AVI files contain at least one stream (e.g., the video) that you do not have the right codec for.

So it looks like you still haven't found the right codec.

Does the file play in Windows Media Player or VLC (for example)?




回答2:


If you just need the duration of a file, you can try using IMediaDet. I have an example of usage here: http://wpfmediakit.codeplex.com/SourceControl/changeset/view/41623#245585



来源:https://stackoverflow.com/questions/3260120/programmatically-get-video-duration

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