美文网首页
搭建简单的实时视频服务

搭建简单的实时视频服务

作者: 一笔春秋 | 来源:发表于2017-09-30 16:34 被阅读37次

    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

    相关文章

      网友评论

          本文标题:搭建简单的实时视频服务

          本文链接:https://www.haomeiwen.com/subject/mifnextx.html