I'm writing a user script for downloading videos. The flash player of the web site use a JSON file.
The purpose of my script is to get the url of the video by downloading and parsing the video according to the web page. Currently it can download an extract the URL of the videos successfully.
The important part of the JSON file look like this :
{
"ammProfile": "AMM-HBBTV",
"version": "VF",
"versionProg": "1",
"VFO": "HBBTV",
"VMT": "mp4",
"VUR": "http://vo.llnwd.net/v2/am/HBBTV/051332-074-A_SQ_2_VF_01464306_MP4-2200_AMM-HBBTV.mp4"
}, {
"ammProfile": "AMM-HBBTV",
"version": "VF",
"versionProg": "1",
"VFO": "HBBTV",
"VMT": "mp4",
"VUR": "http://vo.llnwd.net/v2/am/HBBTV/051332-074-A_EQ_2_VF_01464315_MP4-1500_AMM-HBBTV.mp4"
}
Both URL here are about the same video, this just is just the resolution which change.
So, How I can parse the relevant metadata without downloading the whole file? The standard for the H.264 video codec is very hard to read.
I use the xhr range header to download partial content, and then get the file info using videoconverter.js, a JS version of ffmpeg (whose license you should check if you plan to use any of this).
you don't need to load the whole video to get the height:
You can use the Range HTTP header via XMLHttpRequest to get only a portion of the file:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
For example: