dou91736 2018-09-07 11:39
浏览 127

php readfile()仅在某些视频文件上提供错误500

I have a problem with displaying some videos via a php script using readfile(). Some videos give a HTML status 500, others work fine. Something I do wrong, but I have no idea what. Can somebody hint me in the right direction? What might be the reason for error 500 ?

This is a simplified example I tested on my localhost to reproduce the error.

calling script:

<?php
  $videofiles=array("1.mp4", "2.mp4", "3.mp4", "4.mp4");
  for ($i=0; $i < count($videofiles); $i++) {
?>
    <div class="videos">
    <video controls>
        <source src="video.php?v=<?php echo $videofiles[$i]; ?>" type="video/mp4">
    </video>
    </div>
<?php
  }
?>

delivering script video.php:

<?php
  $video=$_GET['v'];  
  header("Content-Type: video/mp4"); 
  header("Content-Length: ".filesize($video));
  readfile($video);
?>

All rights are set correct (if I replace "video.php?v=..." by the direct filepath all videos show). I suspect that it has to do with file size - the larger (> 150MB) are those who do not show, but I don't know... for testing I used videos from the same mobile phone and of the same day without altering them.

  • 写回答

1条回答 默认 最新

  • dragon8997474 2018-09-07 14:47
    关注

    Thanks for the answers!

    I found in the error log:

    PHP
    Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to
    allocate 138174464 bytes)
    

    After that I inserted in the script

    ini_set('memory_limit', '400M' );
    

    this solved the problem.

    评论

报告相同问题?

悬赏问题

  • ¥15 运筹学中在线排序的时间在线排序的在线LPT算法
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧