php - 直播不工作

标签 php ffmpeg video-streaming html5-video

我正在使用 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/

相关文章:

php - 如何从两个表中获取最新的5家公司数据

ffmpeg - 使用 FFMPEG 更改容器会产生 NAL 单元错误

ffmpeg - 如何在 Debian 8 Jessie 上安装 gstreamer0.10-ffmpeg(无安装候选)

iphone - 编写带有嵌入式视频的 iPhone 应用程序

youtube - YouTube视频文件流

php - WooCommerce 仅显示已购买的商品

php - 为什么空事务会保留我的实体(学说)?

java - 用Java实现视频流?

php - 导航 CSS 在 IE/chrome 上没有响应

android - 将 2 个音频文件与 android ffmpeg android 混合