小编use*_*602的帖子

通过php服务器流视频

我在我的服务器上有一个视频,我希望通过html 5视频播放器与PHP流.我找到了一个类(https://gist.github.com/ranacseruet/9826293),但它不适用于大文件.我该怎么做才能正确显示视频?

class VideoStream
{
private $path = "";
private $stream = "";
private $buffer = 102400;
private $start  = -1;
private $end    = -1;
private $size   = 0;

function __construct($filePath) 
{
    $this->path = $filePath;
}

/**
 * Open stream
 */
private function open()
{
    if (!($this->stream = fopen($this->path, 'rb'))) {
        die('Could not open stream for reading');
    }

}

/**
 * Set proper header to serve the video content
 */
private function setHeader()
{
    ob_get_clean();
    header("Content-Type: video/mp4");
    header("Cache-Control: …
Run Code Online (Sandbox Code Playgroud)

php video stream

5
推荐指数
0
解决办法
2万
查看次数

标签 统计

php ×1

stream ×1

video ×1