현재 video.js 및 php를 사용하여 비디오 파일을 스트리밍하려고합니다. HTML을 사용하여 직접 파일을로드 할 수 있지만 PHP를 통해 소스 태그를 통해 비디오의 이름을 전달하려고하면 서버 또는 네트워크가 실패했거나 비디오가로드되지 않아 비디오를로드 할 수 없다는 오류가 발생합니다. 형식이 지원되지 않습니다.php 및 video.js를 사용하여 비디오 파일 스트리밍
<head>
<link href="css/videojs/video-js.css" rel="stylesheet">
<script src="scripts/videojs/video.js"></script>
<script>
videojs.options.flash.swf = "swf/videojs/video-js.swf";
</script>
</head>
$videofilename = $name; // name of the file Eg video.mp4
echo '<video id="player" class="video-js vjs-default-skin vjs-big-play-centered" controls preload="auto" width="640" height="360" poster="images/video_img.png">
<source type="video/mp4" src="uploads/video.php?'.$videofilename.'" >
<p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>
</video>';
echo'<script>
videojs("player", {}, function(){
});
</script>';
video.php 다음 코드
<script>
var query = location.href.split('?');
document.cookie = 'anchor=' + query[1];
</script>
<?php if (!$_COOKIE['anchor']){
echo"<script> window.location.reload() </script>";
}
else
{
$streamname = $_COOKIE['anchor'];
$stream_size = filesize($streamname);
header('Content-Description: File Transfer');
header('Content-type: video/mp4');
header("Content-length: " . filesize($streamname));
header("Expires: 0");
header("Content-Transfer-Encoding: binary");
header("Accept-Ranges: 0-$stream_size");
$file = fopen($streamname, 'r');
echo stream_get_contents($file);
fclose($file);
}
?>
내 브라우저에 저장된 쿠키를 받고 있지 않다
는 그래서 같은 URL에 매개 변수의 이름을 지정 제안 – user3734861