fseek($fd, $NextOffset, SEEK_SET);
For my needs with FLV files, I only need a few metadata info; duration, width, height, frame-rate and any available audio metadata. If I change the above line to...
fseek($fd, $NextOffset, SEEK_CUR);
it stops the continual building of metadata reading of the entire file but still gives me all of the other available metadata info I need *except* for duration.
But since I still need to get the FLV's duration, I've used a different script that's floating on the net for this, which looks like this...
Code: Select all
function GetFLVDuration($file) {
if (file_exists($file)) {
$handle = fopen($file, "r");
$contents = fread($handle, filesize($file));
fclose($handle);
if (strlen($contents) > 3) {
if (substr($contents, 0, 3) == "FLV") {
$taglen = hexdec(bin2hex(substr($contents, strlen($contents) - 3)));
if (strlen($contents) > $taglen) {
$duration = hexdec(bin2hex(substr($contents, strlen($contents) - $taglen, 3)));
return $duration;
}
}
}
}
return false;
}
So either I use getID3 to read the metadata in build-form but can choke the server on big files OR I use the above script to read the entire file and refuses large files altogether.
Doing some further testing, I found that if I change the above script's line 4 to the following...
$contents = fread($handle, 15000);
so it reads the first 15k of the metadata contents from the file, I get a little metadata although encrypted. It gives the following if I echo $contents...
FLV��� ������