.htaccess.php来流式传输视频


.htaccess/php to stream a video?

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

RewriteEngine On
RewriteCond %{REQUEST_URI} '.(mp4|flv|avi)$ [NC]
RewriteRule ^(.*)$ /stream-file.php?filename=$1 [L]

但为此,我认为我需要编写一个通过php流式传输的脚本,并且我无法将其传递给jwplayer等媒体播放器。

或者,我很好奇在这里做这样的网站是怎么可能的:http://www.statsdoesntsuck.com/york/2320.html

如果你查看源代码,你会在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>

EwneWxTl-8JZHlp0n.js的内容可以在这里找到http://content.bitsontherun.com/players/EwneWxTl-8JZHlp0n.js(脚本太长,无法粘贴到此处)。

基本上,我正在寻找一种方法,使查找文件名或位置变得有点困难,但仍然能够流式传输。它不必100%安全(我知道这无论如何都不可能),但至少它不应该像viewsource那样容易--->url.com/file.mp4

任何想法都将不胜感激。我也在使用joomla,所以如果有任何模块/插件能够为我做到这一点,那也很棒——尽管我不介意从头开始写。

因此,换一种说法——保护文件不被下载(不影响流媒体)以及成为DIY项目而不是付费服务项目的最佳方式是什么。

编辑:1。通过apache寻找解决方案2.我发现了以下带有Apache 的Flowplayer安全流

它的问题是htaccess不允许我流式传输文件,当我删除它时,它会很好地流式传输。如果有人能帮我弄清楚我能做些什么来改变它,那将是一个很棒的

我的.htaccess如下:

 RewriteEngine on
 RewriteRule ^(.*)/(.*)/(.*)$ http://localhost/joomla2/video/video.php?h=$1&t=$2&v=$3
 RewriteRule ^$ - [F]
 RewriteRule ^[^/]+'.(mov|mp4)$ - [F]

目前它显示为"找不到文件"。

是的,很容易做到。这是我为视频流代理编写的工作脚本

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绑定,我听说ffserver是最好的选择。

你可能还想试试nginx的nginxrtmp模块。

对于apache,还有一个流模块。

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