ffmpeg+nginx将rtsp转为rtmp

1、安装ffmpeghtml

1.http://ffmpeg.org/download.html下载地址,选择合适的操做系统版本下载,由于个人操做系统是centos7,因此下面的安装都是命令都是针对centos系统的nginx

2.安装ffmpeg依赖的软件x264git

sudo yum install x264-devel.x86_64github

3.配置ffmpegcentos

./configure --enable-gpl --enable-libx264app

4.编译(时间有点长)tcp

makecentos7

5.安装操作系统

make installcode

2、安装nginx

1.官网下载源码http://nginx.org/

2.到github上,下载rtmp-module,https://github.com/arut/nginx-rtmp-module,在后面配置nginx须要用到

3.安装openssl,配置nginx须要,sudo yum install openssl-devel.x86_64

4.配置nginx,进入到nginx源码目录

./configure --add-module=/path/to/nginx-rtmp-module

5.编译

make

6.安装 

make install

7.修改nginx配置文件

添加

rtmp{

  server{

    listen 1935;

    chunk_size 4000;

    application mylive{

      live on;

    }

  }

}

3、运行软件

1.启动nginx

nginx -c /path/to/nginx.conf

2.启动ffmpeg

ffmpeg -re -rtsp_transport tcp -i "rtsp://用户名:密码@摄像机IP地址:RTSP端口/h264/ch1/main/av_stream" -f flv -vcodec libx264 -vprofile baseline -acodec aac -ar 44100 -strict -2 -ac 1 -f flv -s 1280x720 -q 10 "rtmp://本机地址:1935(nginx.conf的rtmp模块下listen)/mylive(rtmp模块下application设置)/test(随便取名字)"

相关文章
相关标签/搜索