[英]How to get video length / duration programatically in C# (Universal windows apps)?
I've searched about this for a while, and most answers seem to suggest using the directshow library, which I've tried, but it didn't work. 我已经搜索了一段时间,大多数答案似乎都建议使用DirectShow库,该库我已经尝试过了,但是没有用。 My program currently works on selecting a video file using the FileOpenPicker, then checks its length and uploads it to the cloud if it's below a certain length.
我的程序当前正在使用FileOpenPicker选择视频文件,然后检查其长度,如果长度不足则将其上传到云中。 Please keep in mind that this needs to work for Universal Windows Apps.
请记住,这需要适用于Universal Windows Apps。
You can use DirectShow API MediaDet
object, through DirectShow.NET wrapper library. 您可以通过DirectShow.NET包装器库使用DirectShow API
MediaDet
对象。 See Getting length of video for code sample, get_StreamLength
gets you the duration in seconds. 请参阅获取视频长度以获取代码示例,
get_StreamLength
可以获取持续时间(以秒为单位)。 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).You can use DirectShow API MediaDet
object, through DirectShow.NET wrapper library. 假设Windows已安装MPEG-4解复用器(Windows 7之前需要使用Windows的第三方组件,我相信cezor的另一个答案也是如此 ,不过可以随意重新分发组件)。您可以通过DirectShow使用DirectShow API
MediaDet
对象。 .NET包装器库。 See Getting length of video for code sample, get_StreamLength
gets you the duration in seconds. 请参阅获取视频长度以获取代码示例,
get_StreamLength
可以获取持续时间(以秒为单位)。 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). 假定Windows已安装MPEG-4多路分解器(Windows 7之前需要使用Windows的第三方组件,我相信cezor的另一答案也是如此 ,不过可以自由地重新分发组件)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.