首页 > 移动开发 > IOS > iOS关于直播 - 搭建服务端解析
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
(滑动显示更多)
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
( 滑动显示更多)
brew tap homebrew/nginx
brew install nginx-full --with-rtmp-module
( 滑动显示更多)
brew info nginx-full
nginx
文件内容说明:
rtmp是协议名称
server 说明内部中是服务器相关配置
listen 监听的端口号,rtmp协议的默认端口号是1935
application 访问的应用路径是zbcs
live on 开始实时
record off 不记录数据
nginx -s reload
brew install ffmpeg
ffmpeg -re -i 你的视频文件的绝对路径(如/Users/lideshan/Downloads/Demo.mp4) -vcodec copy -f flv rtmp://localhost:1935/zbcs/room
( 滑动显示更多)
rtmp://localhost:1935/zbcs/room
sudo /usr/local/nginx/sbin/nginx -s stop sudo /usr/local/nginx/sbin/nginx
( 滑动显示更多)
server { listen 8080; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location/ { root html; index index.html index.htm; } #HLS配置开始,这个配置为了‘客户端‘能够以http协议获取HLS的拉流 location /hls{ # Serve HLS fragments types { application/vnd.apple.mpegurlm3u8; video/mp2t ts; } root html; add_ header Cache-Control no-cache; } #HLS配置结束 #error_page 404 /404.html; # redirect server error pages to the static page / 50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #}
( 滑动显示更多)
rtmp { server { listen 1935; application zbcs { live on; revord off; } application live { live on; revord off; } #增加对HLS支持开始 application hls { live on; hls on; hls_path /usr/local/var/www/hls; hls_fragment 5s; } #增加对HLS支持结束 }}
( 滑动显示更多)
说明:
live on 开启实时
hls on 开启hls
hls_path ts文件存放路径
hls_fragment 5s 每个TS文件包含5秒的视频内容
nginx -s reload
进行推流
ffmpeg -re -i /Users/jiangys/Documents/Document/demo.mp4 -vcodec copy -f flv rtmp://localhost:1935/hls/movie
( 滑动显示更多)
/usr/local/var/www/hls
测试拉流
1用rtmp:(使用VLC验证播放)
rtmp://192.168.1.109/hls/movie
2 用HLS播放
http://192.168.1.109:8080/hls/movie.m3u8
( 滑动显示更多)
补充:
rtmp://192.168.31.185/live/testrtmp://192.168.31.185/live2/test
rtmp://192.168.31.185/hls/movie
rtmp://192.168.31.185/hls/movie
http://192.168.31.185:8080/hls/movie.m3u8
( 滑动显示更多)
作者:阿华12年
链接:https://juejin.cn/post/7000552835712712740
你好,这里是逻辑iOS技术号:一个让知识变得感性,让学习变得轻松!活跃的技术小站,希望给你的生活与技术带来意思不一样!关注公众号,回复“
面试题”,即可领取更多大厂面试题型哦~ 小逻辑相信我们的生活不止眼前的苟且,还有我们向往的诗和大厂高薪工作~

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70005484/viewspace-2790255/ ,如需转载,请注明出处,否则将追究法律责任。