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