I've been trying to find a library in Nuget that will give me the duration of an MP4 when it is being uploaded to my server. Everything I've come across requires the filepath of the video. Is there anything out there that I can pass a Stream object into to get the duration? Or can I parse the bytes at the beginning of the video to extract the duration (knowing that it is an MP4) ?
Asked
Active
Viewed 482 times
1
-
Possible duplicate of [How to get video duration from mp4, wmv, flv, mov videos](http://stackoverflow.com/questions/10190906/how-to-get-video-duration-from-mp4-wmv-flv-mov-videos) – stuartd Oct 13 '15 at 16:19
-
I saw that topic and tried the library, but it requires the files to be saved on the server. My question is specifically looking for a solution that can take a Stream object. – What-About-Bob Oct 13 '15 at 16:23
1 Answers
2
The duration of an MP4 is stored in the 'moov' box of an m4. The issue is, the moov box can be at the beginning, OR end of a file. So, there is not a guaranteed 100% way to do this.

szatmary
- 29,969
- 8
- 44
- 57
-
1Thanks. Guess I'll have to save the file somewhere first. I'm sending into a cloud-hosted MongoDB and was hoping I could parse the bytes while I had them in memory on my web server. – What-About-Bob Oct 14 '15 at 14:56