流媒体视频服务:快速搭建一个简单的流媒体视频服务(一)

article/2025/9/19 16:13:38

快速搭建一个简单的流媒体视频服务

  • 前言
    • 系统组成
    • RTMP协议简介
    • Red5 概述
    • Red5 服务器搭建

前言

最近自己在研究有关于流媒体播放的技术,网上资料甚少。出于开源精神以及在查阅资料得到各位大佬的帮助,故将自己的心得写下记录,便于分享以及日后维护。
在此极力感谢并推荐雷神(雷霄骅)
个人博客:https://blog.csdn.net/leixiaohua1020

系统组成

一个完整的流媒体系统大致需要三个部分组成:编码器、流服务器和播放器。

编码器通过对内容来源(如MP3文件或者麦克风输入)进行编码,并将编码过的内容发送到流服务器;流服务器再将它们发布到Internet,这样客户端的播放器只要连接到流服务器就可以进行在线播放了。

而本次搭建过程是基于RTMP协议完成。

RTMP协议简介

RTMP播放过程
播放一个RTMP协议的流媒体需要经过以下几个步骤:握手,建立连接,建立流,播放。
RTMP连接都是以握手作为开始的。

1:建立连接阶段用于建立客户端与服务器之间的“网络连接”;
2:建立流阶段用于建立客户端与服务器之间的“网络流”;
3:播放阶段用于传输视音频数据。

Red5 概述

Red5 是一个采用 Java 开发开源的 Flash 流媒体服务器。免费开源使软件更加容易扩展,下载后你可以对源代码进行修改;更加经济,比起 FMS 高昂的费用,Red5 能为一般的应用节约大笔费用;同时服务器端的 Java 面向对象语言比起 FMS 服务器端的 ActionScript2 语言更加成熟。鉴于 Red5 的种种优势,推出不久便被广大用户所接受。

Red 5 支持:

  1. 把音频(MP3)和视频(FLV, F4V, MP4, 3GP)转换成播放流;

  2. 录制客户端播放流, 把摄像头,麦克风等传入的音频视频录制保存到服务器;

  3. 共享对象;

  4. 现场直播流发布;

  5. 远程调用;

  6. 协议:RTMP, RTMPT, RTMPS, and RTMPE。

Red5 服务器搭建

JDK自行安装_本文不做演示

可参考:https://jingyan.baidu.com/article/6dad5075d1dc40a123e36ea3.html

下载Red5:(本人使用版本:1.0.10)
官网:http://red5.org/
GitHub:https://github.com/Red5/red5-server/releases

下载后解压到自己的固定文件夹,如图:
在这里插入图片描述
可以选择在conf/red5.properties文件下修改IP和端口号

# Socket policy
policy.host=0.0.0.0
policy.port=843# HTTP
http.host=192.168.1.115	//可在此修改HTTP  IP地址
http.port=5080
https.port=5443
http.URIEncoding=UTF-8
http.max_headers_size=8192
http.max_keep_alive_requests=-1
http.max_threads=20
http.acceptor_thread_count=10
http.processor_cache=20# RTMP
rtmp.host=192.168.1.115		//可在此修改IP地址
rtmp.port=1935
rtmp.io_threads=8
rtmp.send_buffer_size=65536
rtmp.receive_buffer_size=65536
rtmp.ping_interval=1000
rtmp.max_inactivity=60000
rtmp.max_handshake_time=5000
rtmp.tcp_nodelay=true
rtmp.tcp_keepalive=false
rtmp.default_server_bandwidth=10000000
rtmp.default_client_bandwidth=10000000
rtmp.client_bandwidth_limit_type=2
rtmp.bandwidth_detection=false
rtmp.encoder_base_tolerance=5000
rtmp.encoder_drop_live_future=false
# traffic optimization hinting. to disable set traffic class set to -1
# low delay + high throughput == 24 (0x18)
rtmp.traffic_class=-1
# requested maximum length of the queue of incoming connections
rtmp.backlog=32
# the interval (seconds) between each throughput calculation
rtmp.thoughput_calc_interval=15
# enable use of the default mina acceptor
rtmp.default_acceptor=true
# socket i/o pool sizes used when default acceptor is disabled
rtmp.initial_pool_size=0
rtmp.max_pool_size=2
rtmp.max_processor_pool_size=8
rtmp.executor_keepalive_time=60000
mina.logfilter.enable=false
# scheduler configs (per application)
rtmp.scheduler.pool_size=8
rtmp.deadlockguard.sheduler.pool_size=8
# message executor configs (per application) - adjust these as needed if you get tasks rejected
rtmp.executor.core_pool_size=4
rtmp.executor.max_pool_size=32
rtmp.executor.queue_capacity=64
# drop audio packets when queue is almost full, to disable this, set to 0
rtmp.executor.queue_size_to_drop_audio_packets=60
# maximum amount of time allotted to process a single rtmp message / packet in milliseconds, set it as 0 to disable timeout
rtmp.max_handling_time=2000
# connection tweaks - dont modify unless you know what you're doing
rtmp.channel.initial.capacity=3
rtmp.channel.concurrency.level=1
rtmp.stream.initial.capacity=1
rtmp.stream.concurrency.level=1
rtmp.pending.calls.initial.capacity=3
rtmp.pending.calls.concurrency.level=1
rtmp.reserved.streams.initial.capacity=1
rtmp.reserved.streams.concurrency.level=1
# maximum packet size allowed in bytes
rtmp.max_packet_size=3145728# RTMPS
rtmps.host=0.0.0.0
rtmps.port=8443
rtmps.ping_interval=5000
rtmps.max_inactivity=60000
rtmps.max_keep_alive_requests=-1
rtmps.max_threads=8
rtmps.acceptor_thread_count=2
rtmps.processor_cache=20
# RTMPS Key and Trust store parameters
rtmps.keystorepass=password
rtmps.keystorefile=conf/keystore.jks
rtmps.truststorepass=password
rtmps.truststorefile=conf/truststore.jks# RTMPT
rtmpt.host=0.0.0.0
rtmpt.port=8088
rtmpt.ping_interval=5000
rtmpt.max_inactivity=60000
rtmpt.max_handshake_time=5000
rtmpt.max_keep_alive_requests=-1
rtmpt.max_threads=8
rtmpt.acceptor_thread_count=2
rtmpt.processor_cache=20
rtmpt.encoder_base_tolerance=5000
rtmpt.encoder_drop_live_future=true
# better setting for streaming media
rtmpt.target_reponse_size=32768
# best setting for small messages or shared objects
#rtmpt.target_reponse_size=8192
# max incoming messages to process at a time. the most that FP appears to send is 166
rtmpt.max_in_msg_process=166
# max time in millis that we will wait when offering data to the in or out queue
rtmpt.max_queue_offer_time=125
# max offer attempts
rtmpt.max_queue_offer_attempts=4# Debug proxy (needs to be activated in red5-core.xml)
proxy.source_host=127.0.0.1
proxy.source_port=1936
proxy.destination_host=127.0.0.1
proxy.destination_port=1935# JMX
jmx.rmi.host=localhost
jmx.rmi.port=9999
jmx.rmi.sport=9998
jmx.rmi.port.remoteobjects=
jmx.keystorepass=password
jmx.mina.monitor.enable=false
jmx.mina.poll.interval=1000
# Whether to always create the registry in-process, not attempting to 
# locate an existing registry at the specified port. Set to "true" in order
# to avoid the overhead of locating an existing registry when you always intend
# to create a new registry in any case.
jmx.registry.create=true
# Whether or not the MBeanServerFactoryBean should attempt to locate a running 
# MBeanServer before creating one
jmx.reuse.existing.server=true
# Whether to register the MBeanServer with the MBeanServerFactory, making it 
# available through MBeanServerFactory.findMBeanServer()
jmx.register.factory=true
# Whether any threads started for the JMXConnectorServer should be started as daemon threads
jmx.daemon=true
# Whether the JMXConnectorServer should be started in a separate thread
jmx.threaded=true# Server properties
# max events to send in a single update
so.max.events.per.update=64
so.scheduler.pool_size=4
keyframe.cache.entry.max=500
war.deploy.server.check.interval=600000
fileconsumer.delayed.write=true
fileconsumer.queue.size=120
fileconsumer.wait.for.keyframe=true
subscriberstream.buffer.check.interval=5000
subscriberstream.underrun.trigger=100
subscriberstream.max.pending.frames=10
subscriberstream.max.sequential.frames=10
broadcaststream.auto.record=false

启动red5.bat
在这里插入图片描述

出现上图后在浏览器输入:http://IP:port/
如:http://192.168.1.115:5080/
在这里插入图片描述
即代表启动成功!


http://chatgpt.dhexx.cn/article/Hci8IjSZ.shtml

相关文章

用VLC搭建简单的流媒体服务器

在做视频传输客户端开发的时候,经常需要用到流媒体服务,VLC有着非常强大的流媒体处理能力,同时它也可以搭建流媒体服务器。这里介绍一种使用图形化界面搭建RTSP流媒体服务的应用。 (1)打开一个本地的流文件 &#xff…

Linux下视频流媒体服务器搭建详解

目标用于搭建内网流媒体服务器支持视频的点播。 背景 用于支持培训网站中视频点拨功能,在培训网站总体方案中需要加入流媒体服务器,用于存储和传输视频资源。 相关概念 流媒体流媒体(Streaming Media)是一种新兴的网络传输技术…

流媒体服务器搭建亲测有效(srs)

流媒体服务器搭建流程 第一步 去官网下载srs的源码文件官网地址:[https://github.com/ossrs/srs#usage] 说明:建议下载4.0版本,3.0的需要flash的支持。目前谷歌浏览器已经停止了flash的使用。 第二步 按照官网的步骤进行操作 1.进行解压文…

搭建自己的流媒体服务器-(1)服务器搭建篇

搭建自己的流媒体服务器-(1)服务器搭建篇 http://download.csdn.net/download/katdriver/3272133 http://blog.csdn.net/haolipengzhanshen/article/details/50810066 标签: ios流媒体服务器服务器 2016-02-19 15:09 121人阅读 评论(0) 收藏 举报 分…

监控流媒体服务器的搭建和使用

需求的提出 海康、大华、宇视等视频监控系统,都有自己的流媒体服务器平台,为什么要还需要通用的流媒体服务器产品呢? 这个问题可以从几个方面回答:1)经济性: 传统监控厂商的流媒体服务器,由于主…

学着搭建流媒体服务器

操作系统:NAME"openEuler",架构:aarch64,CPU 运行模式:64-bit 目前有多个开发源代码可以搭建流媒体服务,但要先依赖gcc和cmake,所以首先安装gcc和cmake,查了一通资料&…

js逆向工具-初学AST解混淆

目录 一、AST简单了解二、babel环境安装三、快速入门例子1、入门例子讲解:修改变量值2、入门案例代码:修改变量值 四、实际案例1-ob混淆之ast还原1、数组 移位自执行函数 解密字符串函数 还原2、定义的对象Object有规律的key和value 还原3、while swi…

推荐.Net、C# 逆向反编译四大工具利器

转:https://blog.csdn.net/kongwei521/article/details/54927689 在项目开发过程中,估计也有人和我遇到过同样的经历:运行环境出现了重大Bug亟需解决、或者由于电脑挂了、旧代码覆盖新代码,而在这种情况下,我们不能直接…

某科技js逆向

分析 地址->https://qimingp*.cn/fino*a/project/ 捕获ajax请求,发现返回的数据是加密的,如下图: 打开搜索,定位如下: 经过查找,定位到11058行,如下: 分析代码,发现首…

BUUCTF 逆向工程(reverse)之内涵的软件

用IDA32位打开 一看到这个就是知道这里是获取flag的关键(因为花括号{})。一开始以为是用了某种加密方式需要转换一下。结果它显示的:{49d3c93df25caad81232130f3d2ebfad}这部分就是flag。 所以这题的flag为:flag{49d3c93df25caa…

010Editor逆向分析

主要内容: 010Editor介绍 16进制编辑器:16进制修改、文本修改、模板解析各种文件格式、对比文件 010暴力破解分析 1、找到注册的窗口 2、测试注册窗口的反应 3、根据反应做出下一步分析 猜测API,API下断点动态调试 敏感字符串,程序…

Web前端——CSS伪类和伪元素

CSS伪类: 1.伪类的概念: 可以理解为描述元素的某种状态,用于当已有元素处于的某个状态时,为其添加对应的样式,这个状态是根据用户行为而动态变化的。 2.伪类的语法: 标签:伪类{设置的样式,伪类…

CSS伪类

CSS中伪选择器有两种分别是伪元素选择器和伪类选择器。为了向后续版本兼容,伪元素选择器常用"::"开头,而伪类选择器用“:”开头。本篇主要讲解以下伪类选择器: :first-child:last-childonly-childonly-of-type:nth-child(n)nth-la…

【JavaScript 逆向】AST 技术反混淆

前言 通过浏览器工具可以清楚的看到网站正在运行的 HTML 和 JavaScript 代码,所以对 JavaScript 代码进行混淆处理是一些网站常用的反爬措施,例如下文介绍到的字符串混淆、控制流平坦化等,这使得 JavaScript 的可读性变得很差,难以…

Css预编译神器

最近,有靓仔吐槽在编译css代码时,每次写选择器都会变成CV大神,虽说有CV加持但是呢依然会觉得很麻烦,毕竟手速不像年轻时候那样为所欲为 在这里呢给推荐大家用一款神级插件,也是小编参与完成的轻量级插件–sass&#x…

CSS 伪类

CSS 伪类 CSS 伪类是添加到选择器的关键字,用于指定所选元素的特殊状态。例如,伪类 :hover 可以用于选择一个按钮,当用户的指针悬停在按钮上时,设置此按钮的样式。 举例说明: button:hover {color: blue; }伪类由冒号&#xff…

逆向分析并修改Hello World程序《逆向工程核心原理》《软件逆向工程原理与实践》

文章目录 OllyDbg窗口及快捷键步骤1:VS生成需逆向的文件步骤2:OllyDbg中打开该程序的exe文件,找到需修改的位置步骤3:修改修改1:修改指令修改2:修改字符串修改3:输出任意英文 软件逆向工程原理与…

js逆向案例-css字体反爬

目录 一、反爬点二、反爬分析1、js逆向解密响应参数2、css字体伪元素分析一、反爬点 案例网站响应参数js加密, css字体伪元素隐藏,以及style取值等逻辑判断 二、反爬分析 1、js逆

SQL 结构化查询语言

导读 MySql是我们常用的数据库,javaEE常用几款(Oracle,PostgreSQL,DB2或IBM),SQLite是用于嵌入式设备里的小型数据库,例如Android或IOS,而掌握SQL语句,就相当于掌握了所有的常见关系化数据库,需要同学们重点掌握以及经常复习 MySQL数据库服务器、数据库和表的关系 一般一个项…

《数据库系统》(三) 结构化查询语言

hello大家好,今天我们来学习结构化查询语言。教妹学数据库,没见过这么酷炫的标题吧?“语不惊人死不休”,没错,标题就是这么酷炫。 我的妹妹小埋18岁,校园中女神一般的存在,成绩优异体育万能,个性温柔正直善良。然而,只有我知道,众人眼中光芒万丈的小埋,在过去是一个…