如何从 mp4、wmv、flv、mov 视频中获取视频时长 [英] How to get video duration from mp4, wmv, flv, mov videos

查看:91
本文介绍了如何从 mp4、wmv、flv、mov 视频中获取视频时长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的.其实我主要需要mp4格式.但是,如果也可以获取其他类型,那就太好了.我只需要读取文件的持续时间.我怎样才能用 C# 4.0 做到这一点?

Alright. Actually i need mostly the mp4 format. But if it is possible to get for other types as well that would be nice. I just need to read the duration of the file. How can i do that with C# 4.0 ?

所以我需要的就是这个视频:13 分 12 秒

So the thing i need is like this video is like : 13 minutes 12 seconds

我也可以使用 3 个第三方 exe.就像他们将有关文件的信息保存到文本文件中一样.我可以解析那个文本文件.

I can use 3 third party exes too. Like they save the information about the file to a text file. I can parse that text file.

谢谢.

推荐答案

您可以使用 DirectShow API MediaDet 对象,通过 DirectShow.NET 包装库.有关代码示例,请参阅获取视频长度get_StreamLength 获取持续时间秒.这假设 Windows 安装了 MPEG-4 解复用器(需要 Windows 7 之前的第三方组件,我相信这同样适用于另一个 由 cezor 回答,不过可以免费重新分发组件).

You can use DirectShow API MediaDet object, through DirectShow.NET wrapper library. See Getting length of video for code sample, get_StreamLength gets you the duration in seconds. This assumes Windows has MPEG-4 demultiplexer installed (requires third party components with Windows prior to 7, I believe the same applies to another answer by cezor, there are free to redistribute components though).

这篇关于如何从 mp4、wmv、flv、mov 视频中获取视频时长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆