用Java解析远程文件的FLV标头(持续时间) [英] Parsing FLV header (duration) of remote file in Java
问题描述
我正在寻找一个示例,该示例在Java中专门分析持续时间的FLV标头.给定一个FLV文件的URL,我只想下载标题并解析持续时间.我有FLV规范,但我想举个例子. Python或PHP也可以,但首选Java.
I'm looking for an example of parsing an FLV header for duration specifically in Java. Given the URL of an FLV file I want to download the header only and parse out the duration. I have the FLV spec but I want an example. Python or PHP would be OK too but Java is preferred.
推荐答案
下载标头或解析标头时遇到问题吗?如果正在下载,请使用以下代码:
Do you have problems downloading the header or parsing it? if it's downloading then use this code:
URL url = new URL(fileUrl);
InputStream dis = url.openStream();
byte[] header = new byte[HEADER_SIZE];
dis.read(header);
如果要读取int而不是字节,则可以使用DataInputStream包裹InputStream.
You can wrap InputStream with DataInputStream if you want to read int's rather than bytes.
之后,只需查看PHP-FLV Info中的getInfo方法或阅读规范.
After that just look at getInfo method from PHP-FLV Info or read the spec.
这篇关于用Java解析远程文件的FLV标头(持续时间)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!