.htaccess/php以流式传输视频?

.htaccess/php以流式传输视频?,php,apache,.htaccess,streaming,Php,Apache,.htaccess,Streaming,是否可以允许视频从网站直接流式传输,但不允许使用.htaccess下载视频并将请求发送到php文件 RewriteEngine On RewriteCond %{REQUEST_URI} \.(mp4|flv|avi)$ [NC] RewriteRule ^(.*)$ /stream-file.php?filename=$1 [L] 但对于这一点,我假设我需要编写一个通过php流式传输的脚本,而我无法将它传递给媒体播放器,如jwplayer 或者,我很好奇,像这个网站这样的事情怎么可能发生:

是否可以允许视频从网站直接流式传输,但不允许使用.htaccess下载视频并将请求发送到php文件

RewriteEngine On
RewriteCond %{REQUEST_URI} \.(mp4|flv|avi)$ [NC]
RewriteRule ^(.*)$ /stream-file.php?filename=$1 [L]
但对于这一点,我假设我需要编写一个通过php流式传输的脚本,而我无法将它传递给媒体播放器,如jwplayer

或者,我很好奇,像这个网站这样的事情怎么可能发生:

如果查看源代码,您将在html中找到一部分,该部分引用主页上的视频

<div style="background-color:#404040; border-radius:5px;">                              
<div style="width:98%; height:auto; margin-right:auto; margin-left:auto; padding-top:6px">

<script type="text/javascript" src="http://content.bitsontherun.com/players/EwneWxTl-8JZHlp0n.js">
</script>

</div>
</div>

目前,它显示为“未找到文件”。

如果您不受apache的约束,我听说这是一种方法

你也可以试试nginx的

在apache中,还有一个问题


最后,您可能只想尝试众多CDN服务中的一种。我知道你说过你不想使用服务,但我觉得不提是愚蠢的。许多开发人员认为CDNs是默认的选择(包括我自己)。

< P>是的,很容易做到。下面是我为视频流代理编写的工作脚本-

ob_start();

**// do any user checks here - authentication / ip restriction / max downloads / whatever**

**// if check fails, return back error message**

**// if check succeeds, proceed with code below**

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

$opts['http']['header']="Range: ".$_SERVER['HTTP_RANGE'];

**// to add multiple headers to the final request, do something like

**// $opts['http']['header']="Range: ".$_SERVER['HTTP_RANGE']."\r\nHeader1: value1\r\nHeader2: value2";

$opts['http']['method']= "HEAD";

$conh=stream_context_create($opts);

$opts['http']['method']= "GET";

$cong= stream_context_create($opts);

$out[]= file_get_contents($real_file_location_path_or_url,false,$conh);

$out[]= $http_response_header;

ob_end_clean();

array_map("header",$http_response_header);

readfile($real_file_location_path_or_url,false,$cong);

您只是在寻找使用apache的解决方案吗?如果是这样的话,请添加那个标签。谢谢,有一点修改,这只是我需要的…我没有意识到我需要动态交付它。谢谢
ob_start();

**// do any user checks here - authentication / ip restriction / max downloads / whatever**

**// if check fails, return back error message**

**// if check succeeds, proceed with code below**

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

$opts['http']['header']="Range: ".$_SERVER['HTTP_RANGE'];

**// to add multiple headers to the final request, do something like

**// $opts['http']['header']="Range: ".$_SERVER['HTTP_RANGE']."\r\nHeader1: value1\r\nHeader2: value2";

$opts['http']['method']= "HEAD";

$conh=stream_context_create($opts);

$opts['http']['method']= "GET";

$cong= stream_context_create($opts);

$out[]= file_get_contents($real_file_location_path_or_url,false,$conh);

$out[]= $http_response_header;

ob_end_clean();

array_map("header",$http_response_header);

readfile($real_file_location_path_or_url,false,$cong);