问题描述
我有一个实时流式传输代码,并且我在本地主机上流化了我的网络摄像头.
Hi i have a live streaming code and i stream my web cam on the local host.
这是我的流文件代码
<?php
function flush_buffers(){
ob_end_flush();
ob_flush();
flush();
ob_start();
}
header('Content-Type: video/mpeg');
$stream = fopen( 'http://localhost:8080/stream.mp2v', "rb" );
#$save = fopen("save.mp4", "w");
while ( ! feof( $stream ) )
{
$response = fread( $stream, 8192 );
echo $response;
#fwrite($save,$stream);
flush_buffers();
}
fclose( $stream );
fclose($save);
exit();
我需要做的是将此实时流同时记录到一个文件中,我在代码中声明了save.mp4.它无法保存任何内容.mp4.我认为fwrite不适合我的目的.在这一点上我需要帮助.我该怎么办?
What I need to do is record this live streaming simultaneously to a file here i stated save.mp4 in my code.I tried to do that with fwrite but when i run the program with this code i could see my webcam running but it could not record anything to save.mp4.I dont think fwrite is a suitable function for my purpose.I need help in this point.What should i do?
推荐答案
我应该写fwrite($save,$response);
而不是of fwrite($save,$stream);
.它以这种方式工作.
I should have written fwrite($save,$response);
instead of fwrite($save,$stream);
. It worked in this way.
这篇关于php录制实时流式传输到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!