Finding the dimension (height x width) of a MP4 file being uploaded
asp.net-4.0, c#, dimension, mp4
Solution
Rather than solving this problem on the server, you can solve it on the client at view time with the HTML5 `video` element.
$("#video").bind("loadedmetadata", function () {
var width = this.videoWidth;
var height = this.videoHeight;
// ...
});
Using this approach your upload solution can remain untouched.
If storing the dimensions in the database is a requirement, consider finding a way to leverage the `video` element during the upload process. One approach would be to have a video 'preview' step right after upload that would extract the dimensions with the JavaScript code above and post them as hidden form elements to your server.
Problem
My ASP.NET / C# web app allows users to upload MP4 files to a database for later display using the HTML5 `<video>` tag. What I am looking for is a way (code, component) to determine the on-screen dimension that a given MP4 file will need to properly play. I haven't been able to find anything so far. Given a MP4 file (as a file upload) - how can I determine the on-screen dimensions of the video contained in it, using C# code? Is there something like MP4 metadata that can be read from the file?