views:

285

answers:

1

I would like to know the size of the movie I am watching on any video site [ if not possible on all video sites, then at least on YouTube ]. So is it possible, say I will specify the complete path like: 'http://www.youtube.com/watch?v=7xyuX7u-Xts' , to calculate the size of the Flash video (.flv) using JavaScript?

Note
*By saying size I meant filesize, not the dimension. Sorry if it was creating any ambiguity. [ @cristoph ]

+3  A: 

Yes. Look for the content-length in the header with an XmlHttpRequest if you're looking to find out the .swf filesize.

Edit: If you're looking for the actual video size that gets streamed to your computer and not the just the player's filesize, you probably will have to do a little estimation. Take the total bitrate in kbits per second for the video and multiply it by the number of seconds of the video length, which is available in the video page javascript source:

yt.setConfig({
//... (snip)
   'SWF_ARGS': {..., "length_seconds": "727", ...}
//... (snip)
}

Hope this helps get you started.

Mike Atlas
I think Rakesh want's to know the video's dimensions and not its filesize
Christoph
@cristoph, actually i am interested in filesize, let me edit my question.
Rakesh Juyal
Err, so, not the .swf filesize, but the size of the actual video content streamed by youtube's player?
Mike Atlas
@mike: exactly! you are getting me right. that certainly means i will have to get the actual path of the video by some magic, and then i have to calculate the size using, may be, the answer you just gave.
Rakesh Juyal
Check out my edit.
Mike Atlas
@Mike: awesome, lets end this by accepting the answer :)
Rakesh Juyal
Cheers, Rakesh.
Mike Atlas