mp4 à partir de PHP - ne joue Pas dans la balise Vidéo HTML5

Je suis en utilisant la balise video pour la lecture de vidéos.

I utilisation de php les fichiers pour la lecture comme ceci:

    <video id="playvideo" preload="auto" width="845" height="395" 
    poster="http://video-js.zencoder.com/oceans-clip.png">

    <source src="../getvideo_webm.php" type='video/webm' />
    <source src="../getvideo_mp4.php" type='video/mp4'/>
    <source src="../getvideo_ogv.php" type='video/ogg' />

    </video>

Tous .les fichiers php sont jouer très bien quand je les consulter directement dans le navigateur.
Mais la configuration ci-dessus avec toutes les .php comme les fichiers source ne sera pas lu.
Si je donne une droite .mp4 source, il va jouer fine.

L'getvideo_mp4.php ressemble à ceci:

 $path = 'oceans-clip.mp4';
 if (file_exists($path))
 {
 $size=filesize($path);
 $fm=@fopen($path,'rb');
 if(!$fm) {
 //You can also redirect here
 header ("HTTP/1.0 404 Not Found");
 die();
 }
 $begin=0;
 $end=$size;
 if(isset($_SERVER['HTTP_RANGE'])) {
 if(preg_match('/bytes=\h*(\d+)-(\d*)[\D.*]?/i',   
 $_SERVER['HTTP_RANGE'],$matches)){
 $begin=intval($matches[0]);
 if(!empty($matches[1])) {
 $end=intval($matches[1]);
 }
 }
 }
 if($begin>0||$end<$size)
 header('HTTP/1.0 206 Partial Content');
 else
 header('HTTP/1.0 200 OK');
 header("Content-Type: video/mp4");
 header('Accept-Ranges: bytes');
 header('Content-Length:'.($end-$begin));
 header("Content-Disposition: inline;");
 header("Content-Range: bytes $begin-$end/$size");
 header("Content-Transfer-Encoding: binary\n");
 header('Connection: close');
 $cur=$begin;
 fseek($fm,$begin,0);
 while(!feof($fm)&&$cur<$end&&(connection_status()==0))
 { print fread($fm,min(1024*16,$end-$cur));
 $cur+=1024*16;
 usleep(1000);
 }
 die();
 }

Donc ce que je fais mal ?

  • MAINTENANT... il semble que c'EST en TRAVAILLANT avec le code ci-dessus.. :-/
  • Bon Travail Niels...
InformationsquelleAutor Niels | 2013-05-24