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. 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. Please keep in mind that this needs to work for Universal Windows Apps.
-
You might want to tell us will file formats you're supporting. Getting length of a DVD is different than of an AVI file for example. – Complexity Aug 25 '15 at 09:58
-
I guess I'd like to support as many formats as possible down the road, but for now I'm using MP4 files only – Ibraheem Nofal Aug 25 '15 at 10:25
1 Answers
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).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).
-
I did try the method provided in the first link of your answer prior to posting this question, but it didn't work. It threw an exception and gave me a "class not registered" error. That's why I was hoping to find a solution that'd work when developing for windows universal apps – Ibraheem Nofal Aug 25 '15 at 11:32