【发布时间】:2014-12-07 22:25:21
【问题描述】:
我的客户希望他的视频被隐藏,并且不能被下载或复制(或至少使其难以复制)。
我正在尝试使用 flowplayer 安全流媒体,但我无法成功!
我收到此错误:
200,找不到流,NetStream.Play.StreamNotFound,剪辑:'[剪辑] '安全/ad722768cfa6f10b51b7e317c8dd1ca4/1417957647/v.mp4"
它说没有找到视频,但它应该放在 secure/v.mp4 上(对吗?)
更新1
我忘了提到我在安全文件夹中有所需的 apache 重写规则……
安全/.htaccess
RewriteEngine on
RewriteBase /secure
RewriteRule ^(.*)/(.*)/(.*)$ video.php?h=$1&t=$2&v=$3
RewriteRule ^$ - [F]
RewriteRule ^[^/]+\.(flv|mp4)$ - [F]
更新2
我做到了!这是一件愚蠢的简单事情:
我用easyphp webserver测试,url是localhost/v/index.html
我做了一个测试,将所有内容从 /v 文件夹移动到根目录,它成功了!
现在我在 htaccess 中了解到,我需要从根目录开始将完整路径放在 RewriteBase 上,在我的情况下,我需要设置这个:
RewriteBase /v/secure
代码:
index.html
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="flowplayer-3.2.13.min.js"></script>
<script>
$(document).ready(function() {
$f("player", "flowplayer-3.2.18.swf", {
plugins: {
secure: {
url: "flowplayer.securestreaming-3.2.9.swf",
timestampUrl: "sectimestamp.php"
}
},
clip: {
baseUrl: "secure",
url: "v.mp4",
urlResolvers: "secure",
scaling: "fit",
}
});
});
</script>
</head>
<body>
<div id="player"></div>
</body>
sectimestamp.php
<?php
echo time();
?>
secure/video.php
<?php
$hash = $_GET['h'];
$streamname = $_GET['v'];
$timestamp = $_GET['t'];
$current = time();
$token = 'sn983pjcnhupclavsnda';
$checkhash = md5($token . '/' . $streamname . $timestamp);
if (($current - $timestamp) <= 2 && ($checkhash == $hash)) {
$fsize = filesize($streamname);
header('Content-Disposition: attachment; filename="' . $streamname . '"');
if (strrchr($streamname, '.') == '.mp4') {
header('Content-Type: video/mp4');
} else {
header('Content-Type: video/x-flv');
}
header('Content-Length: ' . $fsize);
session_cache_limiter('nocache');
header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
header('Pragma: no-cache');
$file = fopen($streamname, 'rb');
print(fread($file, $fsize));
fclose($file);
exit;
} else {
header('Location: /secure');
}
?>
我已经尝试过了 > Flowplayer Secure Streaming with Apache 但我也收到了上述错误。
有人使用 flowplayer 安全流媒体吗?我做错了什么?
【问题讨论】:
标签: security streaming video-streaming flowplayer