FreeSWITCH 视频直播

本文介绍如何在 Nginx 中配置 RTMP 模块以支持视频直播,并结合 FreeSWITCH 实现视频会议功能。文章详细记录了安装过程、配置步骤及测试方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本文转载自:http://mp.weixin.qq.com/s?__biz=MjM5MzIwMzExMg==&mid=2664614192&idx=1&sn=41d4268a62360f0a8284740a3abae9c3&scene=4#wechat_redirect


上一篇文章发过后,有同学问在nginx下如何视频直播,有的同学就自己研究并写了博客,我们把他的全文转载到这里,供大家学习。同时欢迎大家都来投稿,到时赞赏的钱都付稿费噢!

从下面的网址分别下载nginx和nginx-rtmp-module:

http://nginx.org/en/download.html

我下载了1.10.1的版本

https://github.com/arut/nginx-rtmp-module

我目前的现状是已经安装好了nginx 。版本号为 nginx/1.10.1,需要在它的基础上安装rtmp这个模块,可以使用如下的方法实现

cd /date/tools
git clone https://github.com/arut/nginx-rtmp-module.git (克隆 nginx-rtmp-module)
cd /date/tools/nginx-1.10.1
./configure --prefix=/usr/local/nginx  --add-module=/date/tools/nginx-rtmp-module  --with-http_ssl_module --with-debug
make
make install

2.nginx配置

https://github.com/arut/nginx-rtmp-module/wiki/Directives

在原有的/usr/local/nginx/conf/nginx.conf中加入如下配置

  1. rtmp {  

  2.   

  3.     server {  

  4.   

  5.         listen 1935;  

  6.   

  7.         chunk_size 4000;  

  8.         

  9.         #HLS  

  10.   

  11.         # For HLS to work please create a directory in tmpfs (/tmp/app here)  

  12.         # for the fragments. The directory contents is served via HTTP (see  

  13.         # http{} section in config)  

  14.         #  

  15.         # Incoming stream must be in H264/AAC. For iPhones use baseline H264  

  16.         # profile (see ffmpeg example).  

  17.         # This example creates RTMP stream from movie ready for HLS:  

  18.         #  

  19.         # ffmpeg -loglevel verbose -re -i movie.avi  -vcodec libx264   

  20.         #    -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1   

  21.         #    -f flv rtmp://localhost:1935/hls/movie  

  22.         #  

  23.         # If you need to transcode live stream use 'exec' feature.  

  24.         #  

  25.         application hls {  

  26.             live on;  

  27.             hls on;  

  28.             hls_path /usr/local/nginx/html/hls;  

  29.             hls_fragment 5s;  

  30.         }  

  31.     }  

  32. }  

  33.   

  34. http {  

  35.   

  36.     server {  

  37.   

  38.         listen  8080;  

  39.         location /hls {  

  40.             # Serve HLS fragments  

  41.             types {  

  42.                 application/vnd.apple.mpegurl m3u8;  

  43.                 video/mp2t ts;  

  44.             }  

  45.             root html;  

  46.             expires -1;  

  47.         }  

  48.     }  

  49. }  


nginx -t 检查一下语法。

nginx -s reopen重启nginx。

netstat -an |grep 1935  查看1935端口是否开启

tcp        0      0 0.0.0.0:1935            0.0.0.0:*               LISTEN 

netstat -an |grep 8080

cp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN 

这种状态就说明成功了。

在freeswitch中配置mod_av(编解码的模块)   下载vc.tar.gz(注:FreeSWITCH源代码里有个 html5/verto/verto_communicator 目录,安装verto

cd html5/verto/verto_communicator
./debian8-install.sh
执行完将生成dist目录。)

cd /usr/local/freeswitch/conf/autoload_configs/

vim verto.conf.xml打开后添加

<vhosts>
        <vhost domain="localhost">
          <param name="alias" value="seven.local freeswitch.org"/>
          <param name="root" value="/date/tools/vc"/>
          <param name="index" value="index.html"/>
<!--
          <param name="auth-realm" value="FreeSWITCH"/>
          <param name="auth-user" value="freeswitch"/>
          <param name="auth-pass" value="rocks"/>
-->
        </vhost>

      </vhosts>

在</profile>前,如图:


其中里面的<param name = "root"   value="date/tools/vc">   这是vc解压后的地址  这样mod_verto就变成了一个服务器了

这样在freeswitch中load mod_av

用Chrome浏览器访问: https://你的ip:8082/


每一次访问,需要输入你的姓名和电子邮件。


呼叫3500,就可以进入视频会议了。



这时候在freeswitch中执行

conference 3500-121.41.105.36 record rtmp://192.168.3.203/hls


如果你觉得很麻烦

apt-get install crtmpserver -y

/etc/init.d/crtmpserver start

在freeswitch中conference 3500-121.41.105.36 record rtmp://192.168.3.203/live/1

然后就可以在https://www.hlsplayer.net/rtmp-player中输入 rtmp://192.168.3.203/live/1进行观看了

因为之前虚拟机用了1个cpu 1G的内存,所以在转码的时候cpu使用率达到96%,所以要用多个cpu   更大的内存才能流畅的使用。


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值