我正在使用 PHP 流式传输视频文件,一切正常,直到尝试从某个位置开始,例如当我加载具有起始位置的视频文件时
ns.play('flvprovider.php?file=video.flv&pos=156212');
它会寻找但我不会收到元数据,我知道元数据被注入到视频文件的头部,这可能是为什么当我从某个位置加载视频时我无法获取元数据但我不知道是否有在我使用的提供商下方解决此问题的解决方案
set_time_limit(0);
// ----- NO CACHE -----
session_cache_limiter('nocache');
// General header for no caching
$now = gmdate('D, d M Y H:i:s') . ' GMT';
header('Expires: ' . $now); // rfc2616 - Section 14.21
header('Last-Modified: ' . $now);
header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header('Pragma: no-cache'); // HTTP/1.0
// ----- Seek position -----
$seekat = 0;
if( isset($_GET["pos"]))
{
$seekat = intval($_GET["pos"]);
if ($seekat < 0) $seekat = 0;
}
// ----- file -----
$filename = "";
if( isset($_GET["video"]))
{
$filename = htmlspecialchars($_GET["video"]);
}
else
{
$filename = 'media/philosophie1-inj.flv';
}
$ext = strrchr($filename, ".");
// to hide the video file. For example: $prefix = "hide_"
// to get the video file in a directory. For example: $prefix = "videos/"
$prefix = "";
$file = $prefix . $filename;
if (($filename != "") && (file_exists($file)) && ($ext==".flv") || ($ext==".mp4"))
{
header("Content-Type: video/x-flv");
//header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
//Be sure to post the correct Content Length.
if ($seekat > 0) header('Content-Length: ' . (filesize($file)-$seekat));
else header('Content-Length: ' . filesize($file));
if ($seekat != 0)
{
print("FLV");
print(pack('C', 1 ));
print(pack('C', 1 ));
print(pack('N', 9 ));
print(pack('N', 9 ));
}
$fh = fopen($file, "rb");
fseek($fh, $seekat);
while (!feof($fh))
{
//print (fread($fh, 16384));
print (fread($fh, filesize($file)));
}
fclose($fh);
}
else
{
print("<html><body>");
print("Page not found.");
print("</body></html>");
}
谢谢 !!