Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1083512
  • 博文数量: 190
  • 博客积分: 1156
  • 博客等级: 少尉
  • 技术积分: 2153
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-16 15:01
个人简介

go!go!go!

文章分类

全部博文(190)

文章存档

2023年(11)

2022年(13)

2021年(15)

2020年(38)

2019年(3)

2018年(6)

2016年(1)

2015年(16)

2014年(13)

2013年(24)

2012年(46)

分类: 云计算

2021-01-26 11:32:20

编译过程中遇到如下问题
make[2]: Entering directory `/home/vagrant/janus-gateway/html'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/vagrant/janus-gateway/html'
make[2]: Entering directory `/home/vagrant/janus-gateway'
  CC       plugins/plugins_libjanus_recordplay_la-janus_recordplay.lo
In file included from plugins/janus_recordplay.c:268:0:
plugins/../live.h:10:32: fatal error: libavcodec/avcodec.h: No such file or directory
 #include

解决办法
找到ffmpeg的lib所在路径,在Makefile中的 增加如下红色部分
DEFAULT_INCLUDES = -I.
INCLUDES = -I/usr/include/ffmpeg/





make install 时遇到如下问题


/home/vagrant/janus-gateway/live.c:708: undefined reference to `av_packet_alloc'
/home/vagrant/janus-gateway/live.c:724: undefined reference to `av_packet_free'
/home/vagrant/janus-gateway/live.c:727: undefined reference to `av_packet_alloc'
/home/vagrant/janus-gateway/live.c:742: undefined reference to `av_packet_free'
janus-live.o: In function `janus_live_fdkaac_encoder_encode_inernal':
/home/vagrant/janus-gateway/live.c:1524: undefined reference to `av_packet_alloc'
/home/vagrant/janus-gateway/live.c:1551: undefined reference to `av_packet_free'
collect2: error: ld returned 1 exit status
make[2]: *** [janus] Error 1
make[2]: Leaving directory `/home/vagrant/janus-gateway'
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory `/home/vagrant/janus-gateway'
make: *** [install] Error 2


上述错误可能是ffmpeg-devel版本过低,如本人虚拟机centos7.0中安装的ffmpeg为2.1版本,缺失如上函数,通过以下方式解决:

Install FFmpeg on CentOS and RHEL

To install FFmpeg on CentOS and RHEL distributions, you need to enable EPEL and RPM Fusion repository on the system using following commands.

To install and enable EPEL, use following command.

# yum install epel-release

To install and enable RPM Fusion, use following command on your distribution version.

-------------- On CentOS & RHEL 7.x -------------- # yum localinstall --nogpgcheck   -------------- On CentOS & RHEL 6.x -------------- # yum localinstall --nogpgcheck  

After enabling repositories, run the following command to install FFmpeg:

# yum install ffmpeg ffmpeg-devel
# ffmpeg -version
执行编译好之后的janus-gateway-live 出现如下错误
[5450553678925] Still waiting for the answer, queueing this trickle to wait until we're done there...
Sending Janus API response to janus.transport.http (0x7f6b9c001900)
Got a Janus API response to send (0x7f6b9c001900)
Directory exists: /opt/janus_rtp2rtmp/share/janus/recordings
rtmp url:rtmp://localhost:1935/qixi/1707999376890221
[ERR] [live.c:janus_live_fdkaac_encoder_create:1429] init audio encoder avcodec_find_encoder_by_name aac error
New connection on REST API: ::ffff:10.0.2.2
Segmentation fault (core dumped)

查看core文件
(gdb) bt
#0  0x0000000000471974 in janus_live_pub_create (url=0x7f6bd1dde760 "rtmp://localhost:1935/qixi/1707999376890221", acodec=0x4c155f "opus", vcodec=0x4c1569 "pcma") at live.c:74
#1  0x00007f6bd1dee63e in janus_recordplay_handler (data=0x0) at plugins/janus_recordplay.c:1557
#2  0x00007f6beba93540 in g_thread_proxy () at /lib64/libglib-2.0.so.0
#3  0x00007f6be95ecea5 in start_thread () at /lib64/libpthread.so.0
#4  0x00007f6be931596d in clone () at /lib64/libc.so.6

检查代码:
janus_live_fdkaac_encoder_create(int sample_rate, int channels, int bitrate)
{
    janus_aencoder_fdkaac *ec = g_malloc0(sizeof(janus_aencoder_fdkaac));
    ec->sample_rate = sample_rate;
    ec->channels = channels;
    ec->bitrate = bitrate;


    AVDictionary *audio_opt_p = NULL;
    ec->acodec = avcodec_find_encoder_by_name("libfdk_aac");

   ...
}

应该是编译ffmpeg中未打包libfdk_aac引发, 尝试调整 aac,重新编译观察
ffmpeg 采用tag n3.4.8
./configure --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --extra-ldflags='-Wl,-z,relro ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libass --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-nvenc --enable-openal --enable-opengl --enable-libopus --disable-encoder=libopus --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzvbi --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect  --enable-libfdk-aac  --enable-nonfree

采用fdk-aac-0.1.6版本
wget

In file included from plugins/janus_audiobridge.c:628:0:
plugins/plugin.h:158:18: fatal error: glib.h: No such file or directory

0.在live.c的 函数janus_live_pub_create中首行增加
        av_register_all(); //否则会出现无法找到编码器,即:这一行报错 ec->acodec = avcodec_find_encoder_by_name("libfdk_aac");引发core

1.执行 export PLUGINS_CFLAGS=`pkg-config --cflags libavformat glib-2.0`
2.执行 ./configure --prefix=/opt/janus_rtp2rtmp  --enable-post-processing
3. make && make install



阅读(1544) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~