Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting video dimensions before upload, client-side

I have an upload form for an video. The user clicks browse and selects a file. How can I get the video dimensions the moment the user selects the file (before the file is even uploaded to the server). It obviously has to be something client-side with maybe javascript/jquery or flash/flex (prefer js//jquery though), but can either of them do this?

like image 321
zmol Avatar asked Feb 08 '11 11:02

zmol


2 Answers

Unfortunately, the short answer is you can't - You'd need access to scan the file contents using javascript which isn't allowed. Worse than that, even if you could read the file somehow, you'd need to implement a whole host of codecs in JS just to read the header information.

Mark this one as not possible

like image 52
Basic Avatar answered Sep 20 '22 12:09

Basic


In theory you should be able to use the FileReader API - https://developer.mozilla.org/en/DOM/FileReader

Once the file has been read, you can parse out the headers. As far as I know, nobody has ever done this in javascript.

like image 26
John Fawcett Avatar answered Sep 21 '22 12:09

John Fawcett