SRS的时间戳矫正机制

david 2019-09-01 11:15:39 4242

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:关闭时间戳矫正机制。
如果你的编码器只能做到分别单增(对音频和视频分别编码的情况很常见),那么可以关闭时间戳矫正。

Config

在vhost中配置时间戳矫正:

vhost jitter.srs.com {

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;

}
在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流分发的时间戳矫正机制变为关闭,不对时间戳做任何处理。

Winlin 2014.6

声明:本文内容由易百纳平台入驻作者撰写,文章观点仅代表作者本人,不代表易百纳立场。如有内容侵权或者其他问题,请联系本站进行删除。
david
红包 点赞 收藏 评论 打赏
评论
0个
内容存在敏感词
手气红包
    易百纳技术社区暂无数据
相关专栏
置顶时间设置
结束时间
删除原因
  • 广告/SPAM
  • 恶意灌水
  • 违规内容
  • 文不对题
  • 重复发帖
打赏作者
易百纳技术社区
david
您的支持将鼓励我继续创作!
打赏金额:
¥1易百纳技术社区
¥5易百纳技术社区
¥10易百纳技术社区
¥50易百纳技术社区
¥100易百纳技术社区
支付方式:
微信支付
支付宝支付
易百纳技术社区微信支付
易百纳技术社区
打赏成功!

感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~

举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

审核成功

发布时间设置
发布时间:
是否关联周任务-专栏模块

审核失败

失败原因
备注
拼手气红包 红包规则
祝福语
恭喜发财,大吉大利!
红包金额
红包最小金额不能低于5元
红包数量
红包数量范围10~50个
余额支付
当前余额:
可前往问答、专栏板块获取收益 去获取
取 消 确 定

小包子的红包

恭喜发财,大吉大利

已领取20/40,共1.6元 红包规则

    易百纳技术社区