Solved

programmatically get the width and height of quicktime .mov file

Posted on 2015-01-28
8
231 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 24

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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 24

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 24

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
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)

707 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

12 Experts available now in Live!

Get 1:1 Help Now