搭建简单的实时视频服务

1、使用的框架

1、推流:LFLiveKit(github.com/LaiFengiOS/LFLiveKit

2、播放:ijkplayer(https://github.com/Bilibili/ijkplayer

3、服务器:nginx+rtmp+ffmpeg

2、安装Nginx和FFmpeg

brew tap homebrew/nginx

brew install nginx-full --with-rtmp-module

brew install ffmpeg

3、nginx.conf配置:

1、http节点中server节点里添加以下内容:

location / {

    root  html;

    index  index.html index.htm;

}

location /hls {

    types {

        application/vnd.apple.mpegurl m3u8;

        video/mp2t ts;

     }

    root /usr/local/var/www;

    add_header Cache-control no-cache;

}

2、http节点后添加以下rtmp节点内容:

rtmp {

    server {

        listen 1935;

        #直播流配置

        application rtmplive {

             live on;

             #为rtmp引擎设置最大连接数。

             max_connections 1024;

         }

           application hls {

                 live on;

                 hls on;

                 hls_path /usr/local/var/www/hls;

                 hls_fragment 1s;

          }

    }

}

4、ffmpeg推流命令:(桌面)

ffmpeg -f avfoundation -i "1" -vcodec libx264 -preset ultrafast -acodec libfaac -f flv rtmp://localhost:1935/rtmplive/home

ffmpeg -f avfoundation -i "1" -vcodec libx264 -preset ultrafast -acodec libfaac -f flv http://localhost:1935/hls/home.m3u8

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容