nginx-http-flv-module + ffmpeg编译实现http-flv

本文详细介绍了如何在Ubuntu16.04上编译安装nginx-http-flv-module模块和ffmpeg,并配置nginx.conf,通过命令行实现ffmpeg转http-flv直播。首先更新系统并安装依赖,然后编译nginx-http-flv-module,接着直接安装或编译带GPU支持的ffmpeg,最后配置nginx服务器进行http-flv直播。
摘要由CSDN通过智能技术生成

编译nginx-http-flv-module模块

环境
  • 编译安装的环境是ubuntu16.04
更新系统与安装需要的依赖
  1. sudo apt-get update
  2. sudo apt install build-essential
  3. sudo apt install libtool
  4. sudo apt install libpcre3 libpcre3-dev
  5. sudo apt install zlib1g-dev
  6. sudo apt-get install openssl libssl-dev
clone nginx-http-flv-module模块到本地,github地址
  1. sudo mkdir nginx_build
  2. cd nginx_build
  3. sudo apt-get install git
  4. git clone https://github.com/winshining/nginx-http-flv-module.git
官网下载nginx源码包,此处使用的版本是nginx-1.10.3
  1. wget http://nginx.org/download/nginx-1.10.3.tar.gz
  2. tar -zxvf nginx-1.10.3.tar.gz
  3. cd nginx-1.10.3/
  4. ./configure --with-cc-opt=’-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2’ --with-ld-opt=’-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now’ --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads --add-dynamic-module=…/nginx-http-flv-module

说明:–add-dynamic-module指编译为动态模块,会生成一个.so动态库文件,如果不想编译为动态库的形式可以替换为–add-module

  1. make (此处想加快编译速度可以使用 make -j4代替)
  2. make install

至此nginx-http-flv-module模块编译成功

配置nginx
  1. cd /etc/nginx
  2. sudo cp -r /usr/share/nginx/modules ./
  3. sudo vim nginx.conf
    nginx内容如下:

接下来操作ffmpeg

直接安装ffmpeg
  1. sudo apt-get update
  2. sudo apt-get install ffmpeg

至此,采用直接安装方式可以略过以下编译ffmpeg的步骤

编译安装ffmpeg gpu

第一部分,安装cuda
  1. 查看是否有NVIDIA显卡

lspci | grep -i nvidia

  1. 查看操作系统是否cuda 官方支持:

uname -m && cat /etc/*release

  1. 安装gcc g++ 等编译依赖基础库

sudo apt-get install gcc g++ build-essential

  1. 下载安装cuda,cuda9.0地址
  • 安装方式二选一
  • 方式一:下载完CUDA 9.0之后执行如下语句,运行.run文件

sudo sh cuda_9.0.176_384.81_linux.run


说明:单击回车,一路往下运行,直到提示“是否为NVIDIA安装驱动nvidia-384?”,选择否,因为已经安装好驱动程序了,其他的全都是默认,不过要记住安装位置,默认是安装在/usr/local/cuda文件夹下。

  • 方式二:deb安装
  1. -sudo dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb</
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值