Freeswitch使用mod_av录制mp4文件

FreeSwitch配置mp4 录音 录像

源码编译安装 FreeSwitch

服务器 centos

yum install vim git wget lrzsz
yum install autoconf automake libtool openssl* libtiff* libjpeg*

git clone https://github.com/freeswitch/sofia-sip
cd sofia-sip
./bootstrap.sh
./configure
make
make install

git clone https://github.com/freeswitch/spandsp
cd spandsp
./bootstrap.sh
./configure
make
make install

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig


yum install -y https://files.freeswitch.org/repo/yum/centos-release/freeswitch-release-repo-0-1.noarch.rpm epel-release
yum install yum-utils
yum-builddep -y freeswitch --skip-broken
yum install -y yum-plugin-ovl centos-release-scl rpmdevtools

cd /usr/local/src
git clone -b v1.10.5 https://github.com/signalwire/freeswitch.git freeswitch
cd freeswitch
./bootstrap.sh -j
此时可以编辑配置需要编译的freeswitch模块,vi modules.conf 可以注释掉不需要使用的模块。此处我注释掉了mod_av和mod_signalwire
./configure
此处如果遇到“no usable spandsp”异常时,按照官方指示设置下环境变量,之后重新configure
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
make
make -j install
make -j cd-sounds-install
make -j cd-moh-install


查看版本:freeswitch -version

也可在控制台执行:status查看

安装编译遇到问题解决参考链接:

https://blog.csdn.net/HF1203/article/details/123095440

很多问题需要在 freeswitch 的configure 文件中加入一行

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:${PKG_CONFIG_PATH}

freeswitch对媒体方式

媒体代理方式	 	 
a.默认方式	
媒体通过freeswitch,

RTP被freeswtich转发,freeswitch控制编码的协商并在协商不一致时提供语音编码转换能力,
支持录音,二次拨号等。

更适合呼叫中心等富功能应用,但性能相比其他两个也是最差的
b.代理模式(Proxy Media)	
媒体通过freeswitch转发,但是不处理媒体,

RTP通过freewtich转发(只改动sdp c= ip)
freeswtich不控制 sdp参数,只是转发。
通话的终端必须有一致的语音或者视频编码,因为freeswitch此时不支持转码(适合视频编码)
不支持录音, 二次拨号等功能

更适合处理nat问题,
可以考虑用这种模式做一个session border controlor,也适合于外部MCU配合做为视频会议,性能也明显好于a
c.旁路模式(Bypass Media)	
不转发也不处理媒体,FS不会对SDP控制,音视频也不走FS。

此模式下freeswitch更像是一个信令proxy,媒体不会通过freeswitch,sdp消息体不做修改,没有录音,二次拨号等功能

更像是一个信令代理,性能最高,但提供的功能有限

编译libav

1安装基础命令
yum -y install gcc automake autoconf libtool make
yum install gcc gcc-c++
yum -y install bzip2
yum install -y wget
yum install -y vim

2.安装nasm

wget https://www.nasm.us/pub/nasm/releasebuilds/2.13.03/nasm-2.13.03.tar.gz
tar xvf nasm-2.13.03.tar.gz
cd nasm-2.13.03
./configure
make
make install

安装yasm
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar zxvf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure
make
make install

4.安装aac

wget https://jaist.dl.sourceforge.net/project/opencore-amr/fdk-aac/fdk-aac-0.1.6.tar.gz
tar xvf fdk-aac-0.1.6.tar.gz
cd fdk-aac-0.1.6
./configure
make && sudo make install
5.安装libx264


wget http://download.videolan.org/x264/snapshots/x264-snapshot-20191206-2245-stable.tar.bz2
tar xvf x264-snapshot-20191206-2245-stable.tar.bz2
./configure
make && sudo make install


6编译安装 libav
git clone https://freeswitch.org/stash/scm/sd/libav.git
cd libav

CFLAGS="-fPIC" ./configure --enable-pic --enable-shared --enable-libx264 --enable-nonfree --enable-libfdk-aac --enable-gpl 

make CXXFLAGS="-fPIC"
make install
ldconfig 
在freeswitch/src/mod下
执行make mod_av
在freeswitch源代码目录下执行:
make mod_av-install


编译libav报错:

1 libavcodec/libx264.c error: ‘x264_bit_depth’ undeclared

找到/libx264.c文件,将x264_bit_depth改成大写 X264_BIT_DEPTH
然后重新编译libav执行安装

2 报错 /usr/bin/ld: warning: libx264.so.164, needed by /usr/local/lib/libavcodec.so
全局查找 libx264.so.164文件路径 path
find  / -name  libx264.so.164
然后创建软连接
ln -s /path/libx264.so.164  /usr/local/lib/libavcodec.so 

Testing

freeswitch 默认是使用/源码文件下conf中vanilla中的配置,如要使用testing的配置可以这样做:

cd /usr/local/freeswitch/
mv conf  conf.bak
cp /usr/local/src/freeswitch/conf/testing/  ./conf

freeswitch 的mp4文件录制和播放 可以采用mod_av

fs可能要重新加载mod_av

reload mod_av
如果报错
**libx264.so.164: cannot open shared object file: No such file or directory**

全局查找libx264.so.164文件
复制到 /usr/lib/  /usr/lib64/  下

使用testing的配置拨打6010就可以录像了

<extension name="record_video">
<condition field="destination_number" expression="^6010$">
<action application="set" data="enable_file_write_buffering=true" />
    <action application="set" data="record_concat_video=true"/>
    <action application="answer"/>
    <action application="sleep" data="1000"/>
    <action application="record" data="av:///tmp/record_video.mp4"/>
  </condition>
</extension>

使用testing的配置拨打601就可以播放录像了

<extension name="play_video">
  <condition field="destination_number" expression="^6011$">
    <action application="answer"/>
    <action application="sleep" data="1000"/>
    <action application="playback" data="/tmp/record_video.mp4"/>
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值