我正在使用 FFmpeg 来捕获我的屏幕:
ffmpeg -f dshow -i video="UScreenCapture" -r 5 -s 640x480 -acodec libmp3lame -ac 1 -vcodec mpeg 4 -vtag divx -q 10 -f mpegts tcp://127.0.0.1:1234
所以让它流到某个地方。接受者脚本:
error_reporting(E_ALL); /* Allow the script to hang around waiting for connections. */
set_time_limit(30); /* Turn on implicit output flushing so we see what we're getting as it comes in. */
ob_implicit_flush();
$address = '127.0.0.1';
$port = 1234;
$outfile = dirname(__FILE__)."/output.flv";
$ofp = fopen($outfile, 'wb');
if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) { echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n"; sleep (5); die; }
if (socket_bind($sock, $address, $port) === false) { echo "socket_bind() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n"; sleep (5); die; }
if (socket_listen($sock, 5) === false) { echo "socket_listen() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n"; sleep (5); die; }
if (($msgsock = socket_accept($sock)) === false) { echo "socket_accept() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n"; sleep (5); break; }
do {
$a = '';
socket_recv ($msgsock, $a, 65536, MSG_WAITALL);
fwrite ($ofp, $a);
//echo strlen($a)."\r\n";
} while (true);
它似乎将这些东西保存到磁盘上。现在来了html:
我真的不知道该怎么做,但基于一个例子:
<video src="/output.flv"></video>
但它什么也没做。如果我想流式传输实时传入的内容,那又是怎么回事?
最佳答案
HTML 5 视频将不支持 Flv 格式 HTML5 将仅支持以下格式视频
.mp4 = H.264 + AAC
.ogg/.ogv = Theora + Vorbis
.webm = VP8 + Vorbis
在以下站点中学习 HTML5 视频基础知识
HTML5 video basics
如果你想播放 flv,你必须使用 flash 或 Flex 程序或一些 flv 播放器,如 flowplayer
关于php - 直播不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11419730/