PHP Headers with DivX and Matroska

7 replies [Last post]
Crashpunk
Crashpunk's picture
User offline. Last seen 1 year 34 weeks ago. Offline
Joined: 09/17/2009
Posts: 10

Ok, This is a simple php code to hide the video files and if this is you can block him or give him better access to the video to anyone. I always worked perfectly, The problem is that works with DivX and Matroska does not work. (I tried to change the MIME type). Thank posts on the topic.
Code:
HTML File 1
embed ... src='file2.php'>/embed

PHP File 2 (file2.php)
<?php
$filename = 'hello.mkv'; //with DivX File Work and with MKV don´t work
header('Content-Length: '. filesize($filename));
header('Content-Type: video/divx');
header('Content-Disposition: attachment; filename="'.basename($filename).'"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
ob_clean();
flush();
readfile($filename); // send the file
exit; // make sure no extraneous characters get appended
?>

Crashpunk
Crashpunk's picture
User offline. Last seen 1 year 34 weeks ago. Offline
Joined: 09/17/2009
Posts: 10
I Tried this Code with VLC

I Tried this Code with VLC Web Plugin and Work Fine, And with This Code, in Divx Web Player, the .divx Files Work but .mkv don't. The problem must be of the web player

Sample?

Can you give me a URL where I could try it?

Re: PHP Headers with DivX and Matroska

Crashpunk, I suspect this is because the PHP script doesn't handle range requests, which are required for MKV content.

alex, I mean that the server

alex,

I mean that the server will fulfill range requests (requests for a particular range of bytes from the requested resource). For example, web player may request a byte range of 3045-24357, and the server would send back only that part of the file.

You can see the documentation here:
http://www.ietf.org/rfc/rfc2616.txt

Look up the request header "Range" and the response header "Content-Range". Be aware that there are additional headers and status codes relating to range requests to take into consideration also.

BTW I didn't say that PHP doesn't handle range requests, only that the script Crashpunk posted doesn't appear to handle them.

Range requests are standard

Range requests are standard HTTP 1.1 :)

Put this script on a public server and send me a URL I can test it on via PM or to amayo (at) divxcorp [dotcom]. If I can see how the server is responding to requests I may be able to tell why it's not working.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.