我们正在尝试从输出ffmpeg结果的PHP源执行HTTP伪流。
下面是我们用来输出流的代码。如果我直接访问这个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>你知道这会有什么问题吗?
谢谢!
发布于 2014-07-11 20:12:29
jwplayer在读取该格式的变量( has编码特殊字符,如?&)时有问题
最好的方法是在htaccess中重写stream.php的url:
RewriteRule ^stream-video/(.*)/(.*) stream.php?token=$1&file=$2 [QSA,L]通过这种方式,您可以使用以下命令传递文件url:
http://example.com/stream-video/token-optional/filename-or-id.mp4希望这能帮上忙..
顺便说一句,你通过php和X-Mod-H264-Streaming使用flv streaming有什么收获吗?
https://stackoverflow.com/questions/14146995
复制相似问题