如何获得视频的高度和宽度仅具有客户端的一台MP4网址是什么? [英] How to get video height and width from a MP4 URL with client-side only?

查看:254
本文介绍了如何获得视频的高度和宽度仅具有客户端的一台MP4网址是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个用户脚本下载视频。该网站的flash播放器使用JSON文件。
我的脚本的目的是通过下载和根据所述网页解析所述视频获取视频的链接。目前,它可以成功地下载提取的视频的URL。

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.

的JSON文件看起来像这样的重要组成部分:

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.

因此​​,我怎样才能解析相关的元数据,而无需下载整个文件?作为H.264视频codeC的标准是很难的阅读。

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.

推荐答案

您无需加载整个视频以获得高度:

you don't need to load the whole video to get the height:

function getVideoHeight(url, fnCallback){

var video=document.createElement("video");
  video.autoplay=true;
  video.oncanplay=function(){
     fnCallback(this.offsetWidth, this.offsetHeight);
     this.src="about:blank";
     document.body.removeChild(video);   
  };

  document.body.appendChild(video);
  video.src=url;

}


//test:

getVideoHeight(
  "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", 
  function(w,h){ alert( w+"X"+h); }
); // shows: "640X360"

这篇关于如何获得视频的高度和宽度仅具有客户端的一台MP4网址是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆