Mp4 file via php not playing as html5 video

I am trying to output a mp4 video file via PHP. When used through a flash player (e.g. flowplayer), it works great. But when I try to use it as a source in the html5 video tag or directly access the php file, it does not work.

The code I use is as follows:

$filesize = filesize($file); header("Content-Type: video/mp4"); if ( empty($_SERVER['HTTP_RANGE']) ) { header("Content-Length: $filesize"); readfile($file); } else //violes rfc2616, which requires ignoring the header if it invalid { rangeDownload($file); } 

and rangeDownload from http://mobiforge.com/developing/story/content-delivery-mobile-devices Appendix A.

Even when I use the Content-Range header ( Content-Range:bytes 0-31596111/31596112 ), it starts when 30.13 MB of video is uploaded.

0
php mp4 flowplayer
Dec 01 2018-11-12T00:
source share
2 answers

Finally, I found a way to make it work

 header("Content-Type: $mediatype"); if ( empty($_SERVER['HTTP_RANGE']) ) { header("Content-Length: $filesize"); $fh = fopen($file, "rb") or die("Could not open file: " .$file); # output file while(!feof($fh)) { # output file without bandwidth limiting echo fread($fh, $filesize); } fclose($fh); } else //violes rfc2616, which requires ignoring the header if it invalid { rangeDownload($file); } 

It works in the direct link of the php file and inside the html5 tag.
But to work in Flowplayer (and possibly in other flash / html5 players) you need to add the mp4 extension (for example, view.php? Id = XXX & file = type.mp4)

+1
Dec 03 '11 at 11:30
source share

This may be relevant to your browser and what it uses to view video files, i.e. quicktime. The reason it works with Flash is flash buffering and time synchronization, etc. It is usually not recommended that the browser process media files, since it completely depends on the browser configuration and the plug-ins installed by it.

Some browsers automatically download multimedia files that are fully customizable by the browser and the end user.

0
Dec 01 '11 at 10:28
source share



All Articles