Solved

programmatically get the width and height of quicktime .mov file

Posted on 2015-01-28
8
241 Views
Last Modified: 2015-01-29
so lets say you load a .mov file into a quicktime player on a webpage.
how do you determine the size of the video? - width & height.
not the size that you may have set the player to but the size of the video.

thanks
0
Comment
Question by:dgrafx
  • 5
  • 3
8 Comments
 
LVL 34

Accepted Solution

by:
gr8gonzo earned 500 total points
ID: 40577663
You posted this in the Javascript topic area, but this isn't something Javascript can do. Javascript can do an AJAX call to the server and have a server-side script do the job, though.

Basically, you would need ffmpeg loaded on the server. Then you would use a server-side script to execute ffmpeg and pass in the path to the .MOV file after the -i parameter. For example:

ffmpeg -i mymovie.mov

The result should contain a lot of data about the video, including video resolution:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'mymovie.MOV':
  Metadata:
    major_brand     : qt
    minor_version   : 537331968
    compatible_brands: qt  niko
    creation_time   : 2012-09-09 11:11:51
  Duration: 00:03:30.08, start: 0.000000, bitrate: 20637 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt470
bg/unknown/bt470m), 1920x1080 [SAR 1:1 DAR 16:9], 19089 kb/s, 23.98 fps, 23.98 t
br, 24k tbn, 47.95 tbc (default)
    Metadata:
      creation_time   : 2012-09-09 11:11:51
    Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, 2 channels
, s16, 1536 kb/s (default)
    Metadata:
      creation_time   : 2012-09-09 11:11:51
At least one output file must be specified

Open in new window


Basically, if you look at the data for Stream #0:0, you'll see:
bg/unknown/bt470m), 1920x1080 [SAR 1:1 DAR 16:9], 19089 kb/s, 23.98 fps, 23.98 t

Open in new window


...so you can see that the video dimensions are 1920x1080.

A script can run ffmpeg against the MOV file, then parse the output, and return it in your AJAX response.
0
 
LVL 25

Author Comment

by:dgrafx
ID: 40577683
I see - I was hoping it could be done with a loadedmetadata event listener or something similar.
Why is it that mov files can't be read - at least it's size - like an mp4 for example can?
0
 
LVL 34

Expert Comment

by:gr8gonzo
ID: 40577699
No, that event ties to the HTML 5 <video> tag, which only supports a few common formats, but does not support the .mov format.

It's pretty easy to convert .mov to a compatible format, but that's a more permanent change, so if you're just looking for dimensions of a .mov file without converting it, you'll need to use a server-side utility.
0
 
LVL 34

Expert Comment

by:gr8gonzo
ID: 40577714
For what it's worth, FFMpeg works with a LOT of different formats, not just .MOV. So if you were ever considering the possibility of other non-HTML5 formats coming along...
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 25

Author Comment

by:dgrafx
ID: 40577735
ok thanks.
how would i get JUST width and height with ffmpeg?
0
 
LVL 34

Expert Comment

by:gr8gonzo
ID: 40577845
You would need to use a server-side script to execute ffmpeg, capture the output, and parse it out. A regular expression would probably do the trick.

If you don't know PHP or ASP or whatever scripting language you have available to you, then I'd suggest you post a new question in one of those forums (whichever is appropriate) and ask for help in the specifics.
0
 
LVL 25

Author Comment

by:dgrafx
ID: 40577992
ok thanks ...
I was hoping for a width height variable!
0
 
LVL 34

Expert Comment

by:gr8gonzo
ID: 40578053
A regular expression can figure out the values and put them into width/height variables, but something's gotta parse the output first.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now