1、Mac下搭建推流服务器(Nginx+RTMP+FFMpeg)nginx
安装x264git
git clone git://git.videolan.org/x264.git cd x264 ./configure --enable-static --enable-shared make -j8 sudo make install
安装FFMpeggithub
git clone git://source.ffmpeg.org/ffmpeg.git cd ffmpeg ./configure --enable-gpl --enable-nonfree --enable-pthreads --enable-libx264 --enable-libmp3lame make -j8 sudo make install
FFMpeg源码Xcode debugmacos
https://github.com/sfssqs/ffmpeg-xcode
安装Nginx和nginx_rtmp_module插件xcode
git clone https://github.com/nginx/nginx.git git clone https://github.com/arut/nginx-rtmp-module.git cd nginx-v.XXX ./configure --add-module=/path/to/nginx-rtmp-module --with-openssl=/path/to/openssl-v.XXX make -j8 make install
安装VCL服务器
http://get.videolan.org/vlc/3.0.1/macosx/vlc-3.0.1.dmg
配置RTMP Server文件,nginx.confapp
rtmp { server { # 监听端口 listen 1935; chunk_size 4000; application rtmplive { live on; max_connections 1024; } } }
执行 推流命令播放视频less
ffmpeg -re -i ~/Desktop/XXXX.mov -c copy -f flv rtmp://localhost:1935/rtmplive/home
执行 推流命令打开本地摄像头socket
ffmpeg -f avfoundation -framerate 30 -video_size 1280x720 -i "0:0" -vcodec libx264 -preset ultrafast -acodec libmp3lame -ar 44100 -ac 1 -f flv rtmp://localhost:1935/rtmplive/home
执行 播放ide
ffplay rtmp://localhost:1935/rtmplive/home
VLC File->OpenNetwork
rtmp://localhost:1935/rtmplive/home
nginx
# nginx // 启动 # nginx -s stop // 关闭 # lsof -i:8080 // 查看端口占用
error, 端口小于1024的须要root权限,要么提权,要么该端口
nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
he socket API bind() to a port less than 1024, such as 80 as your title mentioned, need root access. here is "Bind to ports less than 1024 without root access" and another easier way is to run nginx as root.
参考:
Android平台RTMP推流:https://www.jianshu.com/p/462e489b7ce0
摄像头相关:https://blog.csdn.net/jeffasd/article/details/71205664