Hi i have a live streaming code and i stream my web cam on the local host.
Here is my stream file code
<?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();
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?
I should have written fwrite($save,$response);
instead of fwrite($save,$stream);
. It worked in this way.