PHP视频流到iPad

PHP视频流到iPad,php,ipad,http-headers,streaming,mp4,Php,Ipad,Http Headers,Streaming,Mp4,我试图通过PHP流mp4视频。我的应用程序从存储在块中的位置加载视频,并为相应的部分提供服务。使用以下标题: header("Content-Type: $contenttype"); header("Content-Length: $filesize"); header('Accept-Ranges: bytes'); 当请求时,它还可以使用以下附加头并输出正确的字节来提供部分内容: header('HTTP/1.1 206 Partial Content'); header("Conten

我试图通过PHP流mp4视频。我的应用程序从存储在块中的位置加载视频,并为相应的部分提供服务。使用以下标题:

header("Content-Type: $contenttype");
header("Content-Length: $filesize");
header('Accept-Ranges: bytes');
当请求时,它还可以使用以下附加头并输出正确的字节来提供部分内容:

header('HTTP/1.1 206 Partial Content');
header("Content-Range: bytes $start-$end/$filesize");
流媒体技术在Chrome和VLC上都非常有效,但在iPad上却不起作用。测试mp4文件已确认可在ipad上运行

有人有这个运气吗?任何建议都将不胜感激

是的,很容易做到。 无需手动设置这些标题。 让服务器自动完成

这里有一个工作脚本-

ob_start();

if( isset($_SERVER['HTTP_RANGE']) )
      $opts['http']['header']="Range: ".$_SERVER['HTTP_RANGE']; 

$opts['http']['method']= "HEAD"; 
$conh=stream_context_create($opts); 
$opts['http']['method']= "GET";
$cong= stream_context_create($opts);
$out[]= file_get_contents($real_file_location_path_or_url,false,$conh); 
$out[]= $http_response_header; 
ob_end_clean(); 
array_map("header",$http_response_header); 
readfile($real_file_location_path_or_url,false,$cong); 
是的,很容易做到。 无需手动设置这些标题。 让服务器自动完成

这里有一个工作脚本-

ob_start();

if( isset($_SERVER['HTTP_RANGE']) )
      $opts['http']['header']="Range: ".$_SERVER['HTTP_RANGE']; 

$opts['http']['method']= "HEAD"; 
$conh=stream_context_create($opts); 
$opts['http']['method']= "GET";
$cong= stream_context_create($opts);
$out[]= file_get_contents($real_file_location_path_or_url,false,$conh); 
$out[]= $http_response_header; 
ob_end_clean(); 
array_map("header",$http_response_header); 
readfile($real_file_location_path_or_url,false,$cong); 

几年后碰巧看到这个,无论如何我会留下我的答案

由于苹果公司使用H.264编码作为视频的默认编码,如果您使用H.264以外的编码解码器,您可能会发现您的视频在本机应用程序上播放顺畅,但在Safari等浏览器中播放不顺畅

在这种情况下,您可能应该在通过php代码流之前使用ffmepg重新编码视频。我觉得你的PHP代码不错


记得添加
--faststart
标志,将
fastmoov
移动到视频的开头,以便它立即开始播放

几年后,我碰巧看到了这一点,无论如何,我将留下我的答案

由于苹果公司使用H.264编码作为视频的默认编码,如果您使用H.264以外的编码解码器,您可能会发现您的视频在本机应用程序上播放顺畅,但在Safari等浏览器中播放不顺畅

在这种情况下,您可能应该在通过php代码流之前使用ffmepg重新编码视频。我觉得你的PHP代码不错

记得添加
--faststart
标志,将
fastmoov
移动到视频的开头,以便它立即开始播放

在查看脚本时,您必须注意什么在查看脚本时,您必须注意什么在