来自远程服务器的php流文件 [英] php stream file from remote server

查看:41
本文介绍了来自远程服务器的php流文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在远程服务器上有一个视频,它的网址是

Let's say I have a video on a remote server and this its url

" http://domain/video-path/video.mp4 "

使用php将视频向后或向前移动的正确方法是什么?

What is the correct way to stream this video using php with the ability to move the video to the backward or the forward..

我知道如何使用 fopen fread 函数流式传输视频,但是我想使用播放器(html5播放器)来缓存视频,以便客户端可以将其向前移动还是后退..谢谢,抱歉我的英语不好.

I know how to stream the video using fopen and fread functions but I wanna the player(html5 player) to cache the video so the client can move it to forward or backward .. thanks and sorry for my bad english .

推荐答案

答案很晚

$remoteFile = 'blabla.com/video5GB.mp4';
play($remoteFile);

function play($url){
    ini_set('memory_limit', '1024M');
    set_time_limit(3600);
    ob_start();
    if (isset($_SERVER['HTTP_RANGE'])) $opts['http']['header'] = "Range: " . $_SERVER['HTTP_RANGE'];
    $opts['http']['method'] = "HEAD";
    $conh = stream_context_create($opts);
    $opts['http']['method'] = "GET";
    $cong = stream_context_create($opts);
    $out[] = file_get_contents($url, false, $conh);
    $out[] = $httap_response_header;
    ob_end_clean();
    array_map("header", $http_response_header);
    readfile($url, false, $cong);
}

这篇关于来自远程服务器的php流文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆