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) ?
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.