python解析Java中远程文件的FLV头(持续时间) 1 周,5 日 Questions & Answers 2466 我正在寻找一个在Java中解析FLV头的例子。给定FLV文件的URL,我只想下载头并解析出持续时间。我有FLV规范,但我想举个例子。Python或PHP也可以,但Java是首选
# 1 楼答案 下载标题或解析标题时有问题吗?如果正在下载,请使用以下代码: URL url = new URL(fileUrl); InputStream dis = url.openStream(); byte[] header = new byte[HEADER_SIZE]; dis.read(header); 如果想读取int而不是字节,可以使用DataInputStream包装InputStream 之后,只需查看PHP-FLV Info中的getInfo方法或阅读规范
# 2 楼答案 正如the-alchemist在this other question中所述: The Red5 project has a class called FLVReader which does what you want. It's LGPL licensed. 我试过了,效果很好。您将需要以下库: Red5 library jar for use when building applications Apache Commons Logging Apache MINA 获取FLV视频持续时间非常简单: FLVReader flvReader = new FLVReader(...); // Can use a File or a ByteBuffer as input long duration = flvReader.getDuration(); // Returns the duration in milliseconds
# 1 楼答案
下载标题或解析标题时有问题吗?如果正在下载,请使用以下代码:
如果想读取int而不是字节,可以使用DataInputStream包装InputStream
之后,只需查看PHP-FLV Info中的getInfo方法或阅读规范
# 2 楼答案
正如the-alchemist在this other question中所述:
我试过了,效果很好。您将需要以下库:
获取FLV视频持续时间非常简单: