场景

RTMP

RTMP协议
(1)是流媒体协议。
(2)RTMP协议是 Adobe 的私有协议,未完全公开。
(3)RTMP协议一般传输的是 flv,f4v 格式流。
(4)RTMP一般在 TCP 1个通道上传输命令和数据。

FFmpeg

FFmpeg是一套可以用来记录、转换数字音频、视频,并能将其转化为流的开源计算机程序。

采用LGPL或GPL许可证。它提供了录制、转换以及流化音视频的完整解决方案。

官方ffmpeg下载地址:FFmpeg

下载之后找到bin下的三个exe文件,只需要这几个即可。

注:

博客:
BADAO_LIUMANG_QIZHI的博客_霸道流氓气质_CSDN博客
关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。

实现

1、下载nginx-rtmp-win64并修改配置文件

github地址:GitHub - zhongwcool/nginx-rtmp-win64

下载之后其配置文件已经添加了rtmp的配置

rtmp {server {listen 1935;application live {live on;}application hls {live on;hls on; hls_path temp/hls; hls_fragment 8s; }}
}

这里的配置的意思是

listen 代表监听端口

application live 跟的是推流请求路径

live on 代表开启实时

hls on 代表开启hls

hls_path 代表rtmp推流请求路径,文件存放路径

hls_fragment 8s 代表每个TS文件包含5秒的视频内容

完整配置


#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 {server {listen 1935;application live {live on;}application hls {live on;hls on;  hls_path temp/hls;  hls_fragment 8s;  }}
}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  main;sendfile        on;#tcp_nopush     on;#keepalive_timeout  0;keepalive_timeout  65;#gzip  on;server {listen       110;server_name  localhost;#charset koi8-r;#access_log  logs/host.access.log  main;location / {root   html;index  index.html index.htm;}#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 configuration##server {#    listen       8000;#    listen       somename:8080;#    server_name  somename  alias  another.alias;#    location / {#        root   html;#        index  index.html index.htm;#    }#}# HTTPS server##server {#    listen       443 ssl;#    server_name  localhost;#    ssl_certificate      cert.pem;#    ssl_certificate_key  cert.key;#    ssl_session_cache    shared:SSL:1m;#    ssl_session_timeout  5m;#    ssl_ciphers  HIGH:!aNULL:!MD5;#    ssl_prefer_server_ciphers  on;#    location / {#        root   html;#        index  index.html index.htm;#    }#}}

所以这里需要在nginx目录下新建temp/hls目录

2、启动nginx

然后双击nginx.exe,启动完成后去任务管理器中查看是否启动成功,如果没有,则去看logs下的错误日志。

3、下载ffmpeg

按照上面下载地址下载ffmpeg,并将视频和ffmpeg.exe放在同一目录下

4、编写启动脚本实现推流

新建start.bat

ffmpeg.exe -re -i D:\test\1.mp4 -vcodec libx264 -acodec aac -f flv rtmp://127.0.0.1:1935/live/badao

其中D:\test\1.mp4 就是本地视频的位置

后面1935是上面nginx中配置的端口

live是nginx中配置推流的路径

badao是这里自定义的推流地址

双击bat启动

5、引流测试

下载VLC

Official download of VLC media player, the best Open Source player - VideoLAN

VLC 是一款自由、开源的跨平台多媒体播放器及框架,可播放大多数多媒体文件,以及 DVD、音频 CD、VCD 及各类流媒体协议。

下载之后安装启动-文件-打开网络串流

输入地址为

rtmp://127.0.0.1:1935/live/badao

效果为

Windows上搭建Nginx RTMP服务器并使用FFmpeg实现本地视频推流相关推荐

  1. 海康摄像机视频rtsp转rtmp,windows下搭建nginx流媒体服务器,使用ffmpeg推流。

    1.运行nginx服务: cmd命令运行切换目录 cd/ e: cd E:\nginx nginx.exe -c conf/nginx-win.conf 2.ffmpeg视频推流 cmd命令切换目录 ...

  2. Windows上搭建rtsp-simple-server流媒体服务器实现rtsp、rtmp等推流以及转流、前端html与Vue中播放hls(m3u8)视频流

    场景 Nginx-http-flv-module流媒体服务器搭建+模拟推流+flv.js在前端html和Vue中播放HTTP-FLV视频流: Nginx-http-flv-module流媒体服务器搭建 ...

  3. linux 搭建nginx + rtmp服务器

    linux 搭建nginx + rtmp服务器 一  环境准备 虚拟机ubuntu 装备,安装一些nginx 必要的依赖和服务 sudo apt-get install libpcre3 libpcr ...

  4. 树莓派搭建nginx+rtmp服务器

    树莓派搭建nginx+rtmp服务器 http://bbs.eeworld.com.cn/thread-506444-1-1.html 1.安装依赖包 sudo apt-get install bui ...

  5. armlinux 搭建nginx + rtmp服务器

    1 综合篇 点我 2 uboot移植 点我 3 uboot lcd驱动 点我 4 kernel移植 点我 5 kernel lcd驱动 点我 6 摄像头驱动 点我 7 ubuntu base移植 点我 ...

  6. Ubuntu18.04搭建nginx rtmp服务器

    1.前言 系统:ubuntu18.04 安装所需要软件下载地址: https://download.csdn.net/download/u010798513/22847289 2. 安装prce 安装 ...

  7. Mac上搭建Nginx + rtmp

    介绍 nginx是非常优秀的开源服务器,用它来做hls或者rtmp流媒体服务器是非常不错的选择,本人在网上整理了安装流程,分享给大家并且作备忘. 安装步骤 1.先安装brew: /usr/bin/ru ...

  8. centos上搭建nginx视频点播服务器(nginx+vod+lua http发送鉴权消息)

    需求背景: 想着搭建一个视频点播服务器,最后选择了nginx+vod的方案,用lua脚本写拉流鉴权,但是环境搭建过程中又发现nginx++vod+lua的环境并不是很容易搭建,是nginx+lua的环 ...

  9. 在windows上搭建一个ftp服务器

    为什么80%的码农都做不了架构师?>>>    一.关于ftp FTP 是File Transfer Protocol的英文简称,而中文简称为"文传协议".用于I ...

最新文章

  1. Docker的使用初探(二):Docker与.NET Core的结合
  2. Python 基础篇-whl文件怎么安装
  3. 利用 Selenium 自动化 web 测试【步骤详解】
  4. 2018年第九届蓝桥杯 - 国赛 - C/C++大学B组 - B. 激光样式
  5. compose配置文件参数详解
  6. 在React和Vue中支持服务器端呈现
  7. [栈应用一] 括号匹配问题
  8. macOS安装配置rzsz(附博主安装过程中的错误解决)
  9. 一键生成 Android 录屏 gif 的脚本
  10. CATIA怎么约束快捷键_CATIA快捷键设置详解
  11. linux笔记本电池管理,Linux系统笔记本电源管理方法实用指南
  12. 用了五年 VS Code ,我决定换成 JetBrains……
  13. 特殊的自然常数π以及e
  14. 关于路由器中设置IP与网关不在同一网段方法的问题
  15. Excel去除含有重复数据所在行
  16. Browser-Solidity的本地安装及使用介绍
  17. 史上最快的内网视频会议部署方案-turbomeeting视频会议系统
  18. 美国旅游签证归来(上海领馆)
  19. C# 委托、事件与Observer模型小案例
  20. Python笔记----使用raise引发异常

热门文章

  1. Luntik and Subsequences 思维
  2. mysql 优化配置 大批量数据插入_php导入大量数据到mysql性能优化技巧
  3. php oop 实际工作,PHP OOP注意点(一)
  4. python怎么从键盘输入两个数然后求和并输出_C语音的题:从键盘输入两个整数,要求求和然后输出和。应该怎么做?...
  5. idea实现抽象类的所有抽象方法_深入理解Java的接口和抽象类
  6. Bat_To_Exe_Converter 乱码 中文
  7. vb6实现union数据结构_数据结构与算法——并查集(不相交集合)
  8. mysql 事务关联_MySQL 关联、联合查询,事务ACID见解
  9. linux7.3搭建dns,Centos7.3搭建DNS服务器--BIND
  10. 关于抢红包的_抢红包系统设计与设计