Windows下用FFmpeg+nginx+rtmp搭建直播环境 实现推流、拉流
參考文章:
Windows下用FFmpeg+nginx+rtmp搭建直播環境 實現推流、拉流:https://www.bbsmax.com/A/MAzAGRAe59/
https://gitee.com/rorgent/zzx-hikvision-Java-demo/tree/master/#%E4%B8%89rtmp%E5%AE%9E%E6%97%B6%E9%A2%84%E8%A7%88
https://blog.csdn.net/u012492535/article/details/79220398
?
?
及流媒體服務器搭建:
1.nignx及nginx-rtmp模塊的安裝
nginx-rtmp的下載,直接下源碼解壓就ok了,我放在這里/home/dev/pengqiuyuan/nginx-rtmp-module-master
https://github.com/arut/nginx-rtmp-module在編譯nginx的時候添加nginx-rtmp模塊的路徑
./configure --add-module=/home/dev/pengqiuyuan/nginx-rtmp-module-master --with-http_ssl_module make make install2.nginx平滑安裝nginx-rtmp
3.nginx.conf的修改(完整的流媒體配置)
(1).chunk_size:流整合的最大的塊大小。默認值為 4096。這個值設置的越大 CPU 負載就越小。這個值不能低于 128。
(2).listen 1935:給NGINX添加一個監聽端口以接收RTMP連接,iptables不需要開放1935端口。
(3).application hls:HLS協議支持。hls_path(m3u8文件生產路徑)、hls_fragment、hls_playlist_length(5個分片,每片11s .注:這樣設置實時直播延時在1分鐘左右)
(4).http請求地址(http://182.92.69.21/hls/test.m3u8)
(5).vlc播放rtmp流(rtmp://182.92.69.21/hls/test)
(6).hls_path和location /hls{alias}的路徑保持一樣如:/home/dev/pengqiuyuan/streaming ,目錄下面保存的是客戶端推送到流服務器的m3u8、ts文件
# For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/user nginx; worker_processes 1;#error_log /var/log/nginx/error.log; #error_log /var/log/nginx/error.log notice; #error_log /var/log/nginx/error.log info;pid /var/run/nginx.pid;events {worker_connections 1024; }rtmp {server{listen 1935;chunk_size 4096;application hls { live on; hls on; hls_path /home/dev/pengqiuyuan/streaming; hls_fragment 11s;hls_playlist_length 55s;allow play all;}} }http {include mime.types;default_type application/octet-stream;sendfile on;keepalive_timeout 65;include /etc/nginx/conf.d/*.conf;server{listen 80;server_name www.fjpqy.cn;access_log logs/redmine.access.log;error_log logs/redmine.error.log info;client_body_buffer_size 128k;proxy_connect_timeout 600;proxy_read_timeout 600;proxy_send_timeout 600;proxy_buffer_size 256k;proxy_buffers 8 256k;proxy_busy_buffers_size 512k;proxy_temp_file_write_size 512k;location /stat{rtmp_stat all;rtmp_stat_stylesheet stat.xsl;}location /stat.xsl{root /home/dev/pengqiuyuan/nginx-rtmp-module-master/;}location /test{alias /home/dev/pengqiuyuan/nginx-rtmp-module-master/test/rtmp-publisher/;}location /hls{#server hls fragmentstypes{application/vnd.apple.mpegurl m3u8;video/mp2t ts;}alias /home/dev/pengqiuyuan/streaming;expires -1;}} }4.客戶端部分,采集桌面視頻以及ffmpeg轉換以及流化音視頻
之前遇到丟幀的問題,real-time buffer 276% full! frame dropped!
問題: https://github.com/rdp/screen-capture-recorder-to-video-windows-free/issues/37桌面音視頻采集成功的例子:
ffmpeg -f dshow -i video=screen-capture-recorder -f dshow -i audio=virtual-audio-capturer -vf scale=1280:720 -vcodec libx264 -r 60.97 -acodec libvo_aacenc -ac 2 -ar 44100 -ab 128 -pix_fmt yuv420p -tune zerolatency -preset ultrafast -f flv "rtmp://192.168.1.50/hls/test"ffmpeg(帶腳本)下載地址,流媒體服務器搭建好之后,修改bat腳本里的推送地址“rtmp://192.168.1.50/hls/test”,直接點擊運行就可以向服務器推送了,之后“/home/dev/pengqiuyuan/streaming”目錄下面會生產m3u8、ts文件就成功了 下載地址: http://download.csdn.net/detail/pqy15005917185/8160799
阿里云就1M的帶寬,被占的滿滿的,下載地址換到csdn上面好了總結
以上是生活随笔為你收集整理的Windows下用FFmpeg+nginx+rtmp搭建直播环境 实现推流、拉流的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 前端学习(1994)vue之电商管理系统
- 下一篇: 计算机操作系统主要特征,计算机操作系统的