- SRS Wiki 首页
- SRS Arch
- ARM转码
- 带宽测试
- 安装
- 客户端 SDK
- 开源的客户端 SDK
- DeliveryHDS
- Delivery HLS
- Delivery HTTP FLV Stream
- Delivery Method
- 分发 RTMP 流
- HttpServer
- DRM
- DVR
- Edge Server
- 功能列表
- Live Streaming Transcode
- 点播 FLV 流
- Forward For Small Cluster
- GIT
- GPERF 内存和性能分析
- gprof 性能分析
- 心跳
- SRS 支持 HEVC 编码
- SRS 简介
- HTTP API
- HTTP Callback
- SRS Embeded HTTP Server
- 集成开发环境
- 采集
- K8S
- Kafka
- SRS 系统服务
- LiveShow
- LogRotate
- 低延时直播应用
- Exec
- OriginCluster
- Perf性能分析
- Performance Banchmark
- Project
- Performance benchmark for SRS on RaspberryPi
- Reload
- REUSE PORT
- WebRTC
- ATC支持HLS/HDS热备
- 分发方式比较
- RTMP Handshake
- URL Specification
- Use Scenarios
- ARM上部署SRS实例
- DASH部署实例
- Demo的部署
- FFMPEG转码部署实例
- RTMP流转发(Forward)部署实例
- HLS部署实例
- SRS-HTTP服务部署实例
- SRS-HTTP-FLV部署实例
- SRS-HTTP-FLV集群部署实例
- Ingest采集实例
- RTMP源站集群部署实例
- RTMP低延时配置
- RTMP部署实例
- RTMP边缘集群部署实例
- SRT deploy example
- 转码后分发HLS部署实例
- Security
- 服务器端开发脚本
- 开始使用
- Snapshot
- SpecialControl
- SRS提供的librtmp
- SRS for linux-arm
- SRS Log System
- SRT媒体编码支持格式
- SRT参数配置
- SRT直播地址格式简介
- SRT
- Streamer
- TimeJitter
- Web P2P
- Windows下的SRS
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
TimeJitter
描述了SRS的时间戳矫正机制。
RTMP Monotonically Increase Timestamp
RTMP要求流的时间戳是单增的,视频流的时间戳单增,音频流的时间戳单增。所谓单增就是指单调递增,所谓单调递增就是包的时间戳越来越大。所谓越来越大就是......数字越来越大。
单增有两种情况:
- 分别单增:指的是视频是单增的,音频是单增的,但是流(混合了音频和视频)是不单增的。
- 流单增:指的不仅仅是分别单增,而且流里面的包永远是单增的。
RTMP协议没有说道要求什么级别的单增,但一般指流单增。
如果非单增会怎样?有些服务器会断开连接,librtmp会报错,flash客户端会播放不了之类。但是,实际上并没有那么恐怖(还是保持单增好点,毕竟RTMP协议里说到这个了),所以有些编码器出来的流不是单增也能播放,特别是用vlc播放之类。
Timestamp Jitter
如果流不是单增的怎么办?SRS采用非常简单的算法保证它是单增的。如果不是单增就把时间戳增量设为40(即fps为25)。这个机制就是SRS的时间戳矫正机制。
有几处地方用到了时间戳矫正:
- RTMP流分发:可以设置vhost的time_jitter来选择矫正机制。分发给客户端的RTMP流的时间戳矫正机制。
- DVR录制:可以设置vhost的dvr的time_jitter来配置矫正机制。录制为flv文件的时间戳处理机制。
- HLS:打开时间戳矫正机制。
- Forward:打开时间戳矫正机制。
- HTTP Audio Stream Fast Cache: 和RTMP一样,即在vhost中配置,参考
fast_cache
.
如果你的编码器只能做到分别单增(对音频和视频分别编码的情况很常见),那么可以关闭时间戳矫正。
Config
在vhost中配置时间戳矫正:
vhost jitter.srs.com {
# for play client, both RTMP and other stream clients,
# for instance, the HTTP FLV stream clients.
play {
# about the stream monotonically increasing:
# 1. video timestamp is monotonically increasing,
# 2. audio timestamp is monotonically increasing,
# 3. video and audio timestamp is interleaved/mixed monotonically increasing.
# it's specified by RTMP specification, @see 3. Byte Order, Alignment, and Time Format
# however, some encoder cannot provides this feature, please set this to off to ignore time jitter.
# the time jitter algorithm:
# 1. full, to ensure stream start at zero, and ensure stream monotonically increasing.
# 2. zero, only ensure sttream start at zero, ignore timestamp jitter.
# 3. off, disable the time jitter algorithm, like atc.
# default: full
time_jitter full;
# whether use the interleaved/mixed algorithm to correct the timestamp.
# if on, always ensure the timestamp of audio+video is interleaved/mixed monotonically increase.
# if off, use time_jitter to correct the timestamp if required.
# default: off
mix_correct off;
}
}
其中,vhost的mix_correct
配置,能将分别单增的音频和视频流,变成混合单增的流。
在DVR中配置时间戳矫正:
vhost dvr.srs.com {
# dvr RTMP stream to file,
# start to record to file when encoder publish,
# reap flv according by specified dvr_plan.
# http callbacks:
# @see http callback on_dvr_hss_reap_flv on http_hooks section.
dvr {
# about the stream monotonically increasing:
# 1. video timestamp is monotonically increasing,
# 2. audio timestamp is monotonically increasing,
# 3. video and audio timestamp is interleaved monotonically increasing.
# it's specified by RTMP specification, @see 3. Byte Order, Alignment, and Time Format
# however, some encoder cannot provides this feature, please set this to off to ignore time jitter.
# the time jitter algorithm:
# 1. full, to ensure stream start at zero, and ensure stream monotonically increasing.
# 2. zero, only ensure sttream start at zero, ignore timestamp jitter.
# 3. off, disable the time jitter algorithm, like atc.
# default: full
time_jitter full;
}
}
ATC
RTMP ATC开启时,RTMP流分发的时间戳矫正机制变为关闭,不对时间戳做任何处理。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论