流式3gp视频不工作mp4正在使用php脚本在浏览器中工作

流式3gp视频不工作mp4正在使用php脚本在浏览器中工作,php,video,browser,Php,Video,Browser,我获取视频文件并转换成字符串,然后使用str_将转换后的字符串拆分为数组。请参阅代码了解详细信息。对于mp4,它可以工作,但当我将标题更改为video/3gpp时,脚本就会下载 <?php $mime_type = "video/3gpp"; $file = "/home/welcome/Videos/abc.3gp"; header("Content-type: $mime_type"); rangeDownload($file); function rangeDownlo

我获取视频文件并转换成字符串,然后使用str_将转换后的字符串拆分为数组。请参阅代码了解详细信息。对于mp4,它可以工作,但当我将标题更改为video/3gpp时,脚本就会下载

<?php

$mime_type = "video/3gpp";


$file = "/home/welcome/Videos/abc.3gp";


header("Content-type: $mime_type");

rangeDownload($file);

function rangeDownload($file) {


    $fp = file_get_contents($file, 'r');
    $a = str_split($fp, 5000);
    $size = filesize($file);
    $length = $size;           // Content length
    $start = 0;               // Start byte
    $end = $size - 1;       // End byte

    header("Accept-Ranges: 0-$length");

    if (isset($_SERVER['HTTP_RANGE'])) {

        $c_start = $start;
        $c_end = $end;
        list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);


        if (strpos($range, ',') !== false) {

            header('HTTP/1.1 416 Requested Range Not Satisfiable');
            header("Content-Range: bytes $start-$end/$size");
            // (?) Echo some info to the client?
            exit;
        }
        if ($range0 == '-') {
            $c_start = $size - substr($range, 1);
        } else {

            $range = explode('-', $range);
            $c_start = $range[0];
            $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size;
        }
        $c_end = ($c_end > $end) ? $end : $c_end;
        if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) {

            header('HTTP/1.1 416 Requested Range Not Satisfiable');
            header("Content-Range: bytes $start-$end/$size");
            exit;
        }
        $start = $c_start;
        $end = $c_end;
        $length = $end - $start + 1;
        header('HTTP/1.1 206 Partial Content');
    }
    // Notify the client the byte range we'll be outputting
    header("Content-Range: bytes $start-$end/$size");
    header("Content-Length: $length");

    foreach ($a as $k) {
        set_time_limit(0);
        echo $k;
        flush();
    }
}

?>

你能重新表述一下你的问题标题吗?当我编写脚本为mp4播放视频时,它在我的浏览器和iphone上工作。但当我将其更改为video/3gpp时,它就不播放视频了。它被下载了。希望它能让你明白我想问的问题。如果没有,请告诉我。$mime_type=video/3gpp$文件=/home/welcome/Videos/abc.3gp;如果您更改$mime_type=video/mp4$file=/home/welcome/Videos/any.mp4;视频并在浏览器上运行代码,然后运行。是否在web服务器的配置文件中添加了MIME支持,例如Apache。您的Web服务器软件是什么?