<?php
// Usage:
// Start steam, open script/page standalone on server.
// $ cvlc v4l2:///dev/video1 :v4l2-standard= :v4l2-width=640 :v4l2-height=480 :input-slave=alsa://hw:0,0 :live-caching=300 :sout="#transcode{vcodec=VP80,acodec=vorb,vb=600,fps=20,channels=1,ab=64,sampelrate=44100,scale=1}:http{dst=:8080/stream.webm}"
function flush_buffers(){
ob_end_flush();
ob_flush();
flush();
ob_start();
}
$stream="http://my.livestream.url:8080/stream.webm";
$file="./stream.webm";
$stream_headers=@get_headers($stream);
if (!$stream_headers || $stream_headers[0]=='HTTP/1.1 404 Not Found') {
exit(1);
} else {
$fh=fopen($file,'w');
$sh=fopen($stream,'r');
echo "Capturing Stream to File...";
while(!feof($sh)) {
$data=fread($sh,1024 * 5);
ftruncate($fh,0);
rewind($fh);
fwrite($fh,$data);
flush_buffers();
}
fclose($sh);
fclose($fh);
}
echo "Stream ended.";
exit(0);
?>
Top