Show Video on iPhone/iPad through PHP

前端 未结 1 923
借酒劲吻你
借酒劲吻你 2021-01-28 09:41

I would like to show an mp4 through the video tag and the source URL of the video is a URL to a YII application. I was using Yii:app->request->sendFile before but the video was

1条回答
  •  攒了一身酷
    2021-01-28 10:37

    Your problem may be from several reason.
    1) You can't create a right video. Try to use a string like this:

    c:\utils\ffmpeg\bin\ffmpeg -i MVI_7386.MOV -acodec aac -ac 2 -strict experimental -b:a 160k -s 640x480 -vcodec libx264 -preset slow -profile:v baseline -level 30 -maxrate 10000000 -bufsize 10000000 -b:v 1200k -pix_fmt yuv420p -f mp4 -threads 2 -async 1 -vsync 1 -y video.ipad.mp4
    

    2) I used this answer with small changes for send video via php. Here is my video.php file:

    0||$end<$size) header('HTTP/1.1 206 Partial Content');
      else header('HTTP/1.1 200 OK');
      header("Content-Type: video/mp4");
      header('Content-Length:'.($end-$begin));
      header("Content-Range: bytes $begin-$end/$size");
      $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();
    }
    

    And the html is very simple:

    
    
    
        
        
        test
    
    
        
    
    
    

    You can see what I done here.

    P.S. Sorry for video. :) I could not find anoter one.

    0 讨论(0)
提交回复
热议问题