How to serve .flv files using PHP?

让人想犯罪 __ 提交于 2019-12-22 05:37:16

问题


I'm building a streaming video site. The idea is that the customers should pay for a membership, login to the system, and be able to view the videos. I'm going with FlowPlayer for showing the actual videos.

The problem now is, the videos need to be stored somewhere publically and the url to the .flv files needs to be passed to flowplayer for it to be able to show them. This creates a problem because anyone can do a view source, download the video, and distribute it all across the internet.

I know some people serve images using php by doing an image header() and then they can do something like:

<img src="image.php?userId=1828&img=test.gif" />

The php script validates the user ID and serves up the .gif and the actual url of the gif is never revealed.

Is there anyway to do this with .flv or any other video format also? E.g, the file and user ID passed onto the PHP script, it validates them, and returns the video?


回答1:


You can set up a directory containing the FLV files on your webserver that can only be accessed by PHP, then in your PHP script you can authenticate the user as usual and simply send a header to the browser telling it to expect an FLV, then echo the raw FLV data:

<?php
// here is where
// you want your
// user authentication

if ($isAuthenticated)
{
  header("Content-type: video/flv");
  echo file_get_contents($pathToFLV);
}
?>

As Chad Birch discussed, this will only prevent people from linking directly to the video - you can't prevent piracy this way.




回答2:


The short answer is that no, you're never going to be able to prevent people from downloading your videos if they want to. There are various ways to make it trickier for them to do it, but there's no foolproof method. You're hitting what is basically the entire problem with DRM - you can't show someone your content without giving it to them unencrypted at some point, and if they can view it, they can rip it.




回答3:


Since your flv player is a flash application, it will always be possible to download and decompile it. When decompiled the actual url to the flv will be visible. So it won't really make any difference if you are using direct url's to the flv movies or something like you described in your question

<img src="image.php?userId=1828&img=test.gif" />



回答4:


Please google the word Pseudostreaming you will get the answer There are some servers like lighttpd which has inherent support for flv streaming....

I hope you will get the answer.........




回答5:


Apache with mod_flvx module also has similar effect like lighttpd.



来源:https://stackoverflow.com/questions/599509/how-to-serve-flv-files-using-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!