首页 技术 正文
技术 2022年11月13日
0 收藏 556 点赞 3,231 浏览 3744 个字

Windows:

1、下载文件:

链接:https://pan.baidu.com/s/1c2LmIHHw-dwLOlRN6iTIMg
提取码:g7sj
2、解压文件:

解压到nginx-1.7.11.3-Gryphon

3、进入windows的cmd;

> cd nginx-1.7.11.3-Gryphon    //进入nginx的目录

> nginx.exe -c conf\nginx-win-rtmp.conf   //运行rtmp配置文件

注意:此时命令行会一直处于执行中 不用理会  也不要关闭

测试:浏览器输入localhost:80  ,查看是否配置nginx启动成功!
4、推流:

ffmpeg -re -i 123.mp4 -vcodec libx264 -acodec aac -f flv rtmp://你的ip地址:1935/live/home

5、拉流:

电脑打开vlc播放器    输入地址:rtmp://你的ip地址:1935/live/home

 Linux:

1、安装工具:

#gcc gcc-c++ perl 编译软件包用

yum install -y net-tools wget unzip gcc gcc-c++ perl

2、安装nginx及rtmp:

#切换的homme目录
cd /home

下载并解压pcre

#下载pcre包
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz
#解压pcre包
tar -zxvf pcre-8.41.tar.gz

下载并解压zlib

#下载zlib包
wget http://www.zlib.net/zlib-1.2.11.tar.gz
#解压zlib包
tar -zxvf zlib-1.2.11.tar.gz

下载并安装openssl

用FFmpeg+nginx+rtmp搭建环境实现推流

#下载openssl包
wget https://www.openssl.org/source/old/1.0.1/openssl-1.0.1i.tar.gz
#解压openssl包
tar -zxvf openssl-1.0.1i.tar.gz
#切换到openssl里
cd openssl-1.0.1i
#生成配置文件 默认配置
./config
#编译程序
make
#安装程序
make install

用FFmpeg+nginx+rtmp搭建环境实现推流

下载并解压nginx-rtmp-model

用FFmpeg+nginx+rtmp搭建环境实现推流

#下载rtmp包
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
#解压下载包
unzip -o master.zip
#修改文件夹名
mv master nginx-rtmp-module

用FFmpeg+nginx+rtmp搭建环境实现推流

安装nginx

#下载

nginx wget http://nginx.org/download/nginx-1.12.2.tar.gz
#解压
nignx tar -zxvf nginx-1.12.2.tar.gz
#切换到nginx中
cd nginx-1.12.2
#生成配置文件,将上述下载的文件配置到configure中
./configure --prefix=/usr/local/nginx --with-pcre=/home/pcre-8.41 --with-zlib=/home/zlib-1.2.11 --with-openssl=/home/openssl-1.0.1i --add-module=/home/nginx-rtmp-module
#编译程序
make
#安装程序
make install
#创建全局命令
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
#查看nginx模块 nginx -V

用FFmpeg+nginx+rtmp搭建环境实现推流

安装FFmpeg:
安装ffmpeg时需要提前安装yasm插件:
cd /home
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3..tar.gz
tar -xvf yasm-1.3..tar.gz
cd yasm-1.3./
./configure && make && make install

开始安装ffmpeg:
cd /home
wget http://www.ffmpeg.org/releases/ffmpeg-3.4.tar.gz
tar -xvf ffmpeg-3.4.tar.gz
cd ffmpeg-3.4/
./configure && make && make install编译成功后测试:
ffmpeg --help

修改nginx配置:

新建配置文件:
vi /usr/local/nginx/conf/nginx-rtmp.conf
输入内容:
#user nobody;
worker_processes 1;
#
##error_log logs/error.log;
##error_log logs/error.log notice;
##error_log logs/error.log info;
#
##pid logs/nginx.pid;
#
#
events {
worker_connections 1024;
}
#RTMP閰嶇疆
rtmp{
server{
listen 1935;
application myapp{
live on;
}
application hls{
live on;
hls on;
hls_path /tmp/hls;
}
}
}
#
http {
include mime.types;
default_type application/octet-stream;
#
##log_format main '$remote_addr - $remote_user [$time_local] "$request" '
## '$status $body_bytes_sent "$http_referer" '
## '"$http_user_agent" "$http_x_forwarded_for"';
#
access_log logs/access.log;
#
sendfile on;
##tcp_nopush on;
#
##keepalive_timeout 0;
keepalive_timeout 65;
#
gzip on;
#include /usr/local/nginx/conf.d/*.conf;
server {
listen 80;
server_name localhost;
#
##charset koi8-r;
#
##access_log logs/host.access.log main;
#
location / {
root html;
index index.html index.htm;
}
location /hls {
types{
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /tmp;
add_header Cache-Control no-cache;
}
##error_page 404 /404.html;
#
## redirect server error pages to the static page /50x.html
##
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
#
## proxy the PHP scripts to Apache listening on 127.0.0.1:80
##
##location ~ \.php$ {
## proxy_pass http://127.0.0.1;
##}
#
## pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
##
##location ~ \.php$ {
## root html;
## fastcgi_pass 127.0.0.1:9000;
## fastcgi_index index.php;
## fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
## include fastcgi_params;
##}
#
## deny access to .htaccess files, if Apache's document root
## concurs with nginx's one
##
##location ~ /\.ht {
## deny all;
##}
#
#
## another virtual host using mix of IP-, name-, and port-based configurati
##error_page 404 /404.html;
#
## redirect server error pages to the static page /50x.html
##

  

执行nginx

/usr/local/nginx/sbin/nginx

关闭防火墙

systemctl stop firewalld
systemctl disable firewalld

测试功能

ffmpeg -re -i 123.mp4 -vcodec copy -codec copy -f flv rtmp://你的ip/hls/cctv

测试访问

视频切片保存位置:/tmp/hls/
m3u8视频访问地址:http://你的ip/hls/cctv.m3u8

 重启nginx

/usr/local/nginx/sbin/nginx -s reload
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,907
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,432
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,247
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,058
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,690
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,727