• 阿里云ECS+Nginx+nginx_rtmp_module+FFMPEG服务器搭建过程


    Nginx下安装nginx-rtmp-module+ffmpeg搭建流媒体服务器。
    参考http://blog.csdn.net/redstarofsleep/article/details/45092147

    阿里云环境
    1. 使用SecueCRT、FlashFXP连接购买的阿里云ECS。
    2. 一般购买后盘是初始化好的。第一次操作忽略这步。挂载新的盘时,可参考初始化盘https://jingyan.baidu.com/article/37bce2be0eeea01002f3a208.html
    3. 在阿里云买的是Ubuntu Java环境,所以需要安装g++编译器( apt-get install g++)。

    Nginx安装
    参考:http://blog.csdn.net/redstarofsleep/article/details/45092127
    1.下载(或从官网下载后上传):
    wget http://nginx.org/download/nginx-1.10.2.tar.gz
    wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz
    wget http://zlib.net/zlib-1.2.11.tar.gz
    wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
    2.解压四个包:tar -xzvf XXXXX.tar.gz。
    3.安装nginx:
    cd /usr/src/nginx-1.10.2
    ./configure --prefix=/usr/nginx --with-pcre=/usr/src/pcre-8.40 --with-zlib=/usr/src/zlib-1.2.11 --with-openssl=/usr/src/openssl-fips-2.0.10
    make
    make install
    进入objs执行./nginx(低版本进入sbin)启动。ps -ef | grep nginx查看进程状态。
    4.测试
    浏览器输入http://公网IP,进入不显示nginx启动画面。
    原因:阿里云安全组没设置80端口对外,新增一组80端口公网http,https访问的安全组规则即可。如何添加看阿里云帮助。
    5.结束进程。./nginx -s stop或者./nginx -s quit

    nginx-rtmp-module安装
    cd /usr/src/nginx-1.10.2
    ./configure --add-module=/usr/src/nginx-rtmp-module
    make && make install

    ffmpeg及三方包安装
    编译安装FFmpeg 要支持xvid、x264、mp3、ogg、amr、faac
    参考:http://blog.csdn.net/redstarofsleep/article/details/45092145
    1.libx264需要nasm,yasm。
    安装yasm:
    wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
    ./configure ; make ; make install
    安装nasm:
    wget http://www.nasm.us/pub/nasm/releasebuilds/2.13/nasm-2.13.tar.gz
    安装libx264:
    注意解压格式tar -jxvf last_x264.tar.bz2
    安装libx264:
    wget ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
    ./configure ; make ; make install
    安装libaac...等包。
    另参考安装FFmpeg:

    libfaac faac格式的编解码包
    libmp3lame mp3格式编解码包
    libopencore-amrwb libopencore-amrnb amr格式编解码包
    libx264 x264格式编解码包
    libvorbis ogg格式编解码包
    libxvid xvid格式编解码包

    开始安装(有些包下载可能需要FQ)
    faac
    wget http://softlayer-dal.dl.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.gz
    tar zxf faac-1.28.tar.gz
    cd faac-1.28
    ./configure prefix=/usr/local/
    make #./common/mp4v2/mpeg4ip.h strcasestr 重复定义报错,暂时注释其。
    make install

    lame : 参考:http://www.linuxfromscratch.org/blfs/view/svn/multimedia/lame.html
    wget http://downloads.sourceforge.net/lame/lame-3.99.5.tar.gz
    tar -zxvf lame-3.99.5.tar.gz
    cd lame*
    说有个编译错误解决下:
    case $(uname -m) in
    i?86) sed -i -e '/xmmintrin.h/d' configure ;;
    esac
    ./configure --prefix=/usr --enable-mp3rtp --disable-static &&
    make
    # make test 可以测试
    make pkghtmldir=/usr/share/doc/lame-3.99.5 install

    libtheora:
    参考http://www.linuxfromscratch.org/blfs/view/svn/multimedia/libtheora.html
    libogg:
    ./configure --prefix=/usr
    --disable-static
    --docdir=/usr/src/ffmpeg/libogg-1.3.2 &&
    make && make check && make install

    libtheora:
    sed -i 's/png_(sizeof)/1/g' examples/png2theora.c &&
    ./configure --prefix=/usr --disable-static &&
    make && make install

    libvorbis:
    wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.xz
    sed -i '/components.png \/{n;d}' doc/Makefile.in
    ./configure --prefix=/usr --disable-static &&
    make
    make install &&
    install -v -m644 doc/Vorbis* /usr/src/ffmpeg/libvorbis-1.3.5

    opencore-amr
    wget http://iweb.dl.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.3.tar.gz
    tar zxf opencore-amr-0.1.3.tar.gz
    cd opencore-amr
    ./configure prefix=/usr/local/
    make && make install

    ogg
    wget http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.xz
    xz -d libogg-1.3.2.tar.xz
    tar xf libogg-1.3.2.tar
    cd libogg-1.3.2
    ./configure prefix=/usr/local/
    make && make install

    xvid
    wget http://downloads.xvid.org/downloads/xvidcore-1.3.3.tar.gz
    tar zxf xvidcore-1.3.3.tar.gz
    cd xvidcore/build/generic/ #注意路径
    ./configure prefix=/usr/local/
    make && make install

    pkg-config:依赖 glib. http://ftp.acc.umu.se/pub/GNOME/sources/glib/2.53/glib-2.53.2.tar.xz
    安装参考:http://blog.csdn.net/chenhezhuyan/article/details/9455625

    ffmpeg
    wget http://ffmpeg.org/releases/ffmpeg-2.4.3.tar.bz2
    tar jxf ffmpeg-2.4.3.tar.bz2
    cd ffmpeg-2.4.3
    失败:
    ./configure --enable-libxvid --enable-libx264 --enable-libmp3lame --enable-libvorbis --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfaac --enable-gpl --enable-version3 --enable-nonfree --enable-shared --enable-zlib --enable-bzlib --enable-libvorbis
    部分包安装失败。先去掉部分包依赖,成功:
    ./configure --enable-libxvid --enable-libx264 --enable-libmp3lame --enable-libvorbis --enable-gpl --enable-version3 --enable-shared --enable-zlib --enable-libvorbis
    make#wait about 10 minutes
    make install

    OVER! 原文链接:http://www.linuxidc.com/Linux/2015-02/112693.htm

    执行 ffmpeg ,报错。分析参考(http://blog.csdn.net/kaka20080622/article/details/40260423):
    ldd `which ffmpeg`
    信息:
    root:/usr/src/ffmpeg/ffmpeg-3.3.1# ldd `which ffmpeg`
    linux-vdso.so.1 => (0x00007fff54cc1000)
    libavdevice.so.57 => not found
    libavfilter.so.6 => not found
    libavformat.so.57 => not found
    libavcodec.so.57 => not found
    libpostproc.so.54 => not found
    libswresample.so.2 => not found
    libswscale.so.4 => not found
    libavutil.so.55 => not found
    解决:
    #find / | grep -E "libavdevice.so.57|libavfilter.so.6|libavformat.so.57|libavcodec.so.57|libpostproc.so.54|libswresample.so.2|libswscale.so.4|libavutil.so.55"
    #edit /etc/ld.so.conf #添加find到的路径
    include ld.so.conf.d/*.conf
    /usr/local/lib
    #ldconfig
    #ffmpeg 显示可以使用了。

  • 相关阅读:
    单例设计模式
    C#做窗体皮肤
    常用的数组的操作
    C#调试方法
    Timer
    程序对对象的字段的代码简写
    nginx upstream的几种配置方式
    ava如何实现系统监控、系统信息收集、sigar开源API的学习(转)
    vsftpd 被动模式与主动模式
    MySQL安装详解(V5.5 For Windows)
  • 原文地址:https://www.cnblogs.com/konglj/p/nginx-rtmp-module-ffmpeg.html
Copyright © 2020-2023  润新知