从 Flash Player Objective-C 获取视频文件
有谁知道如何从此网址获取视频文件的网址:
http://vk.com/video_ext.php?oid=6492&id=141771975&hash=a984f2edb68fc4f7
它返回带有视频的Flash播放器,但iPhone不支持flv格式,并且我想知道视频是 flv 还是 mp4 文件。如果有人知道如何在线播放 flv 视频,我会听:)
Does anybody knows how to get url to video file from this url:
http://vk.com/video_ext.php?oid=6492&id=141771975&hash=a984f2edb68fc4f7
It returns flash player with video, but iphone doesn't support flv format, and i want to know if video is flv or mp4 file. If someone know how to play flv video online, i'm listnening :)
使用 HTTP 流量嗅探器/代理查看页面加载了哪些文件。许多浏览器都将其内置到开发人员工具中(例如 Firebug 中的 net 选项卡),但我更喜欢使用 Charles对于网络开发人员来说还有许多其他有用的功能。
使用 Charles,我可以看到单击播放时加载的文件是 http:// cs12326.vk.com/u06492/video/ab94044f46.flv,这是一个 FLV 文件。
编辑:如果您想以编程方式执行此操作,您可能会运气不好,因为只有视频播放器(在 Flash 中实现)知道从哪个 URL 检索视频文件。您可以针对这个特定网站对其进行逆向工程(见下文),但它显然只适用于 vk.com 上的视频,甚至可能不适用于 vk.com 上的所有视频。
查看 HTML,我可以看到定义了四个看似重要的 javascript 变量:
这些值可以在视频 URL 中找到,因此可以安全地假设通过解析这些变量定义的 HTML 文本,并使用这些值进行编译一个URL,你就可以找到该文件。
我假设在同一段代码中定义的
video_no_flv
变量指示视频是否是 FLV 文件。在此页面中,它设置为0
,因此我假设这意味着它是一个 FLV 文件。这意味着通过在 HTML 文本字符串中搜索子字符串video_no_flv
并解析下一个=
之后的整数,将告诉您该视频文件是否是 FLV文件与否。如果不是,则可以安全地假设它是 MP4/F4V(对于同一类型的 MPEG-4 H.264 文件,这两种文件都有不同的后缀),并且您应该能够在 iPhone 上播放它。如果是这种情况,您应该能够从上述部分编译 URL 并加载它。
要评估这是否真的有效,您需要调查该网站上更大的视频集。
另请注意,应用您通过此类逆向工程获得的知识,并在发布视频的上下文之外显示视频,可能会违反该网站的服务条款,并可能构成重罪。
Use an HTTP traffic sniffer/proxy to see what files get loaded by the page. Many browsers have it built into their developer tools (e.g. the net tab in Firebug), but I prefer to use Charles which has many other useful features for web developers.
Using Charles, I can see that the file that is loaded when I click play is http://cs12326.vk.com/u06492/video/ab94044f46.flv, which is an FLV file.
EDIT: If you want to do this programmatically, you might be out of luck because only the video player (implemented in Flash) knows from which URL to retrieve the video file. You could reverse-engineer it for this particular website (see below) but it will obviously only work for videos on vk.com, and perhaps not even all videos on vk.com.
Looking at the HTML I can see that there are four seemingly important javascript variables being defined:
These values can be found in the video URL, so it's safe to assume that by parsing the HTML text for these variable definitions, and using the values to compile a URL, you can be able to find the file.
I'm assuming that the
video_no_flv
variable that is defined in the same piece of code indicates whether the video is an FLV file or not. In this page it's set to0
, so I'm assuming that means that it is an FLV file. That would mean that by searching through the HTML text string for the sub-stringvideo_no_flv
and parsing the integer after the next subsequent=
will tell you whether the video file is an FLV file or not.If it isn't, it's safe to assume that it's a MP4/F4V (both of which are different suffixes for the same type of MPEG-4 H.264 file) and that you should be able to play it on your iPhone. If that's the case, you should be able to compile the URL from the pieces mentioned above and load it.
To assess whether this will really work, you will need to investigate a larger collection of videos on that site.
Also, note that to implement knowledge that you have gained through this type of reverse engineering, and to display the videos outside of the context in which they have been published, might break that website's terms of service and could be an act of felony.