我正在使用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);
似乎把东西保存到磁盘上OK。现在来了html:
我真的不知道如何做到这一点,但基于一个例子:
<video src="/output.flv"></video>
但它没有做任何事情。如果我想要传输直播的内容,那么问题是什么?
答案 0 :(得分:1)
HTML 5视频不支持Flv格式HTML5将仅支持以下格式视频
.mp4 = H.264 + AAC
.ogg/.ogv = Theora + Vorbis
.webm = VP8 + Vorbis
在以下网站中学习HTML5视频基础知识 HTML5 video basics
如果你想玩flv,你必须使用flash或Flex程序或者一些flv播放器,比如flowplayer