Finding the size (height x width) of the downloaded MP4 file

My ASP.NET/C# web application allows users to upload MP4 files to a database for later display using the HTML5 <video> .

What I'm looking for is a way (code, component) to determine the screen dimension that a given MP4 file should have. I could not find anything yet.

Given the MP4 file (as a file download) - how can I determine the screen sizes of the video contained in it using C # code? Is there something like MP4 metadata that can be read from a file?

+6
source share
1 answer

Instead of solving this problem on the server, you can solve it on the client while viewing using the HTML5 video element.

 $("#video").bind("loadedmetadata", function () { var width = this.videoWidth; var height = this.videoHeight; // ... }); 

Using this approach, your download solution may remain untouched.

If sizing in the database is a requirement, consider how to find a way to use the video element during the download process. One approach would be to immediately show a video preview immediately after downloading, which would extract the dimensions with the JavaScript code above and place them as hidden form elements on your server.

+3
source

All Articles