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);
You can wrap InputStream with DataInputStream if you want to read int's rather than bytes.
After that just look at getInfo method from PHP-FLV Info or read the spec.