PHP在寻找位置时不流式传输元数据

时间:2013-07-15 00:52:24

标签: actionscript-3 netstream pseudo-streaming

我正在使用PHP来传输视频文件,一切正常,直到尝试从一个位置开始 当我加载具有开始位置的视频文件时的问题,例如

ns.play( 'flvprovider.php文件= 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>");
}

谢谢!!

0 个答案:

没有答案