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