/    Sign up×
Community /Pin to ProfileBookmark

How to output an FLV video file with PHP

I tried with something like this:

[code=php]
header(‘Content-Type: video/x-flv’);
readfile(‘path/to/file.flv’);[/code]

But it didn’t work.

This is exactly what I want: in order to hide to the users the real location of the FLV file, and to build a SEF URL, I use .htaccess, so that the file which is being actually pushed into the flash video player (let’s call it videoplayer.swf) through FlashVars, whenever it’s requested, .htaccess redirects the request to a PHP file with GET variables parsed by Apache’s mod_rewrite from the RewriteRule.

e.g.:

[CODE]RewriteRule ^video/([a-ZA-Z0-9_]+)/t([0-9]+)/v([0-9]+).flv video.php?filetype=$2&id=$3 [L][/CODE]

and this one php file (called video.php in the example) outputs the requested file as direct FLV data.

I’m not sure if this is possible because I think you could do this with the flv player (the swf file, called videoplayer.swf in the example), but the flv video file is requested from within Flash afterwards (not with the http protocol I think).

Any suggestion to this? It my apporach is not possible, is there another way?

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@skilled1Apr 18.2011 — whats the reason for trying to hide the file so deep? chances are you will still be able to get the file using : https://addons.mozilla.org/en-US/firefox/addon/video-downloadhelper/
Copy linkTweet thisAlerts:
@JazztronikauthorApr 19.2011 — ok it's not 100% safe to avoid the video download, but I still want to keep the URL SEF by attaching the title alias.

Suggestions?
Copy linkTweet thisAlerts:
@skilled1Apr 19.2011 — now that is a good question lol, sorry i have no further help.
Copy linkTweet thisAlerts:
@lookbookApr 21.2011 — I wrote a script that does this and i used file_get_contents instead of readfile, it worked great.

-lookbook
Copy linkTweet thisAlerts:
@johnceinJul 20.2011 — Unfortunately, the 'Http streaming' option has many bugs. For example, if you seek at any point in the video and when the video is finished, the player returns to the position of the last seek (and not at the beginning of the video)...



Flv Player
×

Success!

Help @Jazztronik spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...