우리는 ffmpeg에서 결과를 출력하는 PHP 소스에서 HTTP 의사 유출을 시도합니다.HTTP JW 플레이어에 PHP w/ffmpeg를 사용하는 의사 소설
아래는 스트림을 출력하는 데 사용하는 코드입니다. 이 URL에 직접 액세스하면 (../stream.php) flv 파일이 다운로드됩니다. JW Player에서 해당 flv 파일을 소스로 사용하면 문제없이 작동합니다. 그러나 stream.php를 소스로 사용하면 작동하지 않으며 "플레이어로드 오류 : 재생할 수있는 소스가 없습니다"
stream.php에서 사용하는 코드는 다음과 같습니다.
header("Accept-Ranges: bytes");
header("Content-type: video/flv");
header("X-Mod-H264-Streaming: version=2.2.7");
$cmd = 'ffmpeg -re -i source.mp4 -map_chapters -1 -vcodec:0 copy -b:v:0 885918 -bf:0 2 -threads:0 0 -s:0 720x404 -partitions:0 +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -acodec:1 copy -b:1 104684 -ac:1 2 -ar:1 44100 -f flv -';
if ($handle = popen($cmd, 'r')) {
sleep(3);
echo fread($handle, 8024000);
ob_flush();
while (!feof($handle)){
echo fread($handle, 8024000);
ob_flush();
}
pclose($handle);
}
우리 JW 플레이어 코드는 다음과 같습니다
<script type="text/javascript">
jwplayer("myElement").setup({
file : "/stream.php?start=0",
provider : 'http',
'http.startparam' :'start',
flashplayer : '/js/jwplayer.flash.swf',
autostart : 'true',
allowscriptaccess:'always',
modes: [
{type: 'html5'},
{type: 'flash'},
{type: 'download'}
],
height: 270,
width: 480
});
</script>
이 잘못 될 수 있는지 어떤 아이디어?
감사합니다.