/** * Return the width, height, mime_type and extension of the given movie file. */ static function get_file_metadata($file_path) { // rWatcher Edit: Use FLVMetaData lib instead of ffmpeg for .flv files. // For other files, just set a 320x240 default video resolution. $pi = pathinfo($file_path); $extension = isset($pi["extension"]) ? $pi["extension"] : "flv"; // No extension? Assume FLV. $mime_type = in_array(strtolower($extension), array("mp4", "m4v")) ? "video/mp4" : "video/x-flv"; $vid_width = 320; $vid_height = 240; if (strtolower($extension) == "flv") { $flvinfo = new FLVMetaData($file_path); $info = $flvinfo->getMetaData(); if ($info["width"] != "" && $info["height"] != "") { $vid_width = $info["width"]; $vid_height = $info["height"]; } } return array($vid_width, $vid_height, $mime_type, $extension); }
$metadata_mp4 = array(); $metadata_mp4 = MP4Info::getInfo($url); $context = new stdClass(); $context = $metadata_mp4; //print_r($context); $metadata["width"] = $context->video->width; $metadata["height"] = $context->video->height; $metadata["duration"] = $context->duration; //$metadata["audiodelay"] = $context->audio->codecStr; $metadata["audiocodecid"] = $context->audio->codec; $metadata["audiocodecStr"] = $context->audio->codecStr; $metadata["videocodecid"] = $context->video->codec; $metadata["videocodecStr"] = $context->video->codecStr; //stdClass Object ( [hasVideo] => 1 [hasAudio] => 1 [video] => stdClass Object ( [width] => 640 [height] => 360 [codec] => 224 [codecStr] => H.264 ) [audio] => stdClass Object ( [codec] => 224 [codecStr] => AAC ) [duration] => 201.316666667 ) } else { $flv = new FLVMetaData($url); //FLVMetaData("0002.flv"); $metadata = $flv->getMetaData(); } $end = microtime(true); ?> <p>Name: <?php echo $flv->fileName; ?> </p> <?php if ($metadata !== false) { ?> <p>FLV Version: <strong><?php echo $metadata["version"];