【问题标题】:How to add timestamp to flowplayer secure streaming plugin (using rtmpe/wowza)如何将时间戳添加到 flowplayer 安全流插件(使用 rtmpe/wowza)
【发布时间】:2013-09-06 11:56:44
【问题描述】:

过去 2 天我一直在寻找解决此问题的方法,因此我们将不胜感激。

我在另一端使用带有 wowza 服务器的自定义令牌(我重新编译了插件 swf)。它运行良好,但人们仍然可以通过链接到我们的 swf 来复制我们的播放器代码并在他们的网站上播放。

我想在我的安全流配置中实现时间戳。我添加了一个时间戳并将 urlResolvers 添加到剪辑部分,但是我的 flowplayer 给我一个错误,它找不到视频(无效链接带有哈希和时间戳)。

我的问题是,如果我在播放器中使用时间戳,我还需要做什么其他配置?我需要对我的 wowza 服务器做些什么吗?因为很明显,加上时间戳,服务器就找不到视频了。

请帮助我提供您拥有的任何信息。谢谢! :)

【问题讨论】:

    标签: security timestamp token flowplayer wowza


    【解决方案1】:

    时间戳用作安全令牌或混淆 URL。你需要做的就是

    // <![CDATA[
      window.onload = function () {
        $f("player", "flowplayer-3.2.16.swf", {
          plugins: {
            secure: {
              url: "flowplayer.securestreaming-3.2.8.swf",
              timestampUrl: "sectimestamp.php"
            }
          },
          clip: {
            baseUrl: "YOUR BASE URL",
            url: "trailer.flv",
            urlResolvers: "secure",
            scaling: "fit",
            onStart: function (clip) {
              document.getElementById("info").innerHTML = clip.baseUrl + "/" + clip.url;
            }
          }
        });
      };
      // ]]>
      </script>
    

    在您的 sectimestamp.php 中,这是一个非常简单的代码行:

    <?php
    echo time();
    ?>
    

    然后你在 video.php 文件中使用类似这样的东西

    $hash = $_GET['h'];
    $streamname = $_GET['v'];
    $timestamp = $_GET['t'];
    $current = time();
    $token = '12359khlsdfhlasiu3'; // I recommend using a dynamically generated token
    $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: /URL/');
    }
    

    这是在 flowplayer 中使用它的一个例子

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-03
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 2011-02-05
      • 2023-01-13
      • 2012-09-05
      • 2014-11-06
      相关资源
      最近更新 更多