当前位置:网站首页>音视频包的pts,dts,duration的由来.
音视频包的pts,dts,duration的由来.
2022-07-05 18:12:00 【hjjdebug】
音视频包的pts,dts,duration的由来.
pts: 演播时间戳
dts:解码时间戳
duration:播放时长
怎样深刻理解这些概念,它们具体代表了什么? 通过具体实例和数据来理解.
包pts:
对于视频包pts, 并不是线性递长的,而是会有浮动, 例如.
以下前12个视频压缩包.
packet count:1 ,stream_index:0,packet_vcount:1,packet_acount:0,pts:133200
packet count:2 ,stream_index:0,packet_vcount:2,packet_acount:0,pts:147600
packet count:3 ,stream_index:0,packet_vcount:3,packet_acount:0,pts:140400
packet count:10 ,stream_index:0,packet_vcount:4,packet_acount:6,pts:136800
packet count:11 ,stream_index:0,packet_vcount:5,packet_acount:6,pts:144000
packet count:12 ,stream_index:0,packet_vcount:6,packet_acount:6,pts:162000
packet count:13 ,stream_index:0,packet_vcount:7,packet_acount:6,pts:154800
packet count:22 ,stream_index:0,packet_vcount:8,packet_acount:14,pts:151200
packet count:23 ,stream_index:0,packet_vcount:9,packet_acount:14,pts:158400
packet count:24 ,stream_index:0,packet_vcount:10,packet_acount:14,pts:176400
packet count:25 ,stream_index:0,packet_vcount:11,packet_acount:14,pts:169200
packet count:26 ,stream_index:0,packet_vcount:12,packet_acount:14,pts:165600
其浮动规律:14400,-7200,-3600,7200,18000,-7200,-3600,7200,18000,-7200,-3600
其实,视频包的duration都是3600.
对于音频包pts, 是线性递长的,例如:
以下14个音频压缩包,每一包pts比前一包多1920, 每一个音频包的duraton是1920
packet count:4 ,stream_index:1,packet_vcount:3,packet_acount:1,pts:131280
packet count:5 ,stream_index:1,packet_vcount:3,packet_acount:2,pts:133200
packet count:6 ,stream_index:1,packet_vcount:3,packet_acount:3,pts:135120
packet count:7 ,stream_index:1,packet_vcount:3,packet_acount:4,pts:137040
packet count:8 ,stream_index:1,packet_vcount:3,packet_acount:5,pts:138960
packet count:9 ,stream_index:1,packet_vcount:3,packet_acount:6,pts:140880
packet count:14 ,stream_index:1,packet_vcount:7,packet_acount:7,pts:142800
packet count:15 ,stream_index:1,packet_vcount:7,packet_acount:8,pts:144720
packet count:16 ,stream_index:1,packet_vcount:7,packet_acount:9,pts:146640
packet count:17 ,stream_index:1,packet_vcount:7,packet_acount:10,pts:148560
packet count:18 ,stream_index:1,packet_vcount:7,packet_acount:11,pts:150480
packet count:19 ,stream_index:1,packet_vcount:7,packet_acount:12,pts:152400
packet count:20 ,stream_index:1,packet_vcount:7,packet_acount:13,pts:154320
packet count:21 ,stream_index:1,packet_vcount:7,packet_acount:14,pts:156240
音频流的采样率.
并且第4个音频包pts:131280比第3个视频包pts:140400 小,但第9个音频包pts140880比第3个视频包大.
第10个视频包pts:136800比第3个视频包pts:140400 还小,比第9个音频包pts也小,但第11个视频包pts就又长上去了.
对于压缩的包,应该看dts. 我们看到视频包也是线性递长的,每次长3600, 这样看着就顺了!!
音频包的dts就等于pts
packet count:1 ,stream_index:0,packet_vcount:1,packet_acount:0,dts:126000,duration:3600
packet count:2 ,stream_index:0,packet_vcount:2,packet_acount:0,dts:129600,duration:3600
packet count:3 ,stream_index:0,packet_vcount:3,packet_acount:0,dts:133200,duration:3600
packet count:4 ,stream_index:1,packet_vcount:3,packet_acount:1,dts:131280,duration:1920
packet count:5 ,stream_index:1,packet_vcount:3,packet_acount:2,dts:133200,duration:1920
packet count:6 ,stream_index:1,packet_vcount:3,packet_acount:3,dts:135120,duration:1920
packet count:7 ,stream_index:1,packet_vcount:3,packet_acount:4,dts:137040,duration:1920
packet count:8 ,stream_index:1,packet_vcount:3,packet_acount:5,dts:138960,duration:1920
packet count:9 ,stream_index:1,packet_vcount:3,packet_acount:6,dts:140880,duration:1920
packet count:10 ,stream_index:0,packet_vcount:4,packet_acount:6,dts:136800,duration:3600
packet count:11 ,stream_index:0,packet_vcount:5,packet_acount:6,dts:140400,duration:3600
packet count:12 ,stream_index:0,packet_vcount:6,packet_acount:6,dts:144000,duration:3600
packet count:13 ,stream_index:0,packet_vcount:7,packet_acount:6,dts:147600,duration:3600
packet count:14 ,stream_index:1,packet_vcount:7,packet_acount:7,dts:142800,duration:1920
packet count:15 ,stream_index:1,packet_vcount:7,packet_acount:8,dts:144720,duration:1920
packet count:16 ,stream_index:1,packet_vcount:7,packet_acount:9,dts:146640,duration:1920
packet count:17 ,stream_index:1,packet_vcount:7,packet_acount:10,dts:148560,duration:1920
packet count:18 ,stream_index:1,packet_vcount:7,packet_acount:11,dts:150480,duration:1920
packet count:19 ,stream_index:1,packet_vcount:7,packet_acount:12,dts:152400,duration:1920
packet count:20 ,stream_index:1,packet_vcount:7,packet_acount:13,dts:154320,duration:1920
packet count:21 ,stream_index:1,packet_vcount:7,packet_acount:14,dts:156240,duration:1920
视频包duration=3600的由来
视频包的r_frame_rate, 从视频流信息中获取(ctx中有)m_fmt_ctx->streams[m_video_stream_index]->r_frame_rate=(25,1)
视频包的time_base, 从视频流信息中获取(ctx中有)m_fmt_ctx->streams[m_video_stream_index]->time_base=(1,90000)
则一帧的时间1/25 = 0.04s = 40ms
转换为视频包时基pts = 0.04 * 90000 = 40*90=3600
音频包duration=1920的由来
音频包的采样率(sample_rate): 由音频流信息(ctx中有)m_fmt_ctx->streams[m_audio_stream_index]->codecpar->sample_rate获取 48000
音频包的大小(frame_size): 由音频流信息(ctx中有)m_fmt_ctx->streams[m_audio_stream_index]->codecpar->frame_size获取 1024
音频包的time_base: 由音频流信息(ctx中有)m_fmt_ctx->streams[m_audio_stream_index]->time_base获取(1,90000)
则一音频包的时间: 1024/48000=0.0213秒
用时基表示时间: 1024/48000*90000=1920
pts 是何时使用呢? 这要把packet压缩包解码成frame 之后, 解出的frame 就是按pts 依次递长排列的了, 将每个frame依次播放就是视频.
附上一段测试数据供参考.
packet count:1 ,stream_index:0,packet_vcount:1,packet_acount:0,pts:133200,dts:126000,duration:3600,size:25709
packet count:2 ,stream_index:0,packet_vcount:2,packet_acount:0,pts:147600,dts:129600,duration:3600,size:9433
packet count:3 ,stream_index:0,packet_vcount:3,packet_acount:0,pts:140400,dts:133200,duration:3600,size:3912
frame count:1 ,frametype:v,frame_vcount:1,frame_acount:0,pts:133200,pkt_size:25709
packet count:4 ,stream_index:1,packet_vcount:3,packet_acount:1,pts:131280,dts:131280,duration:1920,size:69
frame count:2 ,frametype:a,frame_vcount:1,frame_acount:1,pts:131280,pkt_size:69
packet count:5 ,stream_index:1,packet_vcount:3,packet_acount:2,pts:133200,dts:133200,duration:1920,size:425
frame count:3 ,frametype:a,frame_vcount:1,frame_acount:2,pts:133200,pkt_size:425
packet count:6 ,stream_index:1,packet_vcount:3,packet_acount:3,pts:135120,dts:135120,duration:1920,size:830
frame count:4 ,frametype:a,frame_vcount:1,frame_acount:3,pts:135120,pkt_size:830
packet count:7 ,stream_index:1,packet_vcount:3,packet_acount:4,pts:137040,dts:137040,duration:1920,size:427
frame count:5 ,frametype:a,frame_vcount:1,frame_acount:4,pts:137040,pkt_size:427
packet count:8 ,stream_index:1,packet_vcount:3,packet_acount:5,pts:138960,dts:138960,duration:1920,size:424
frame count:6 ,frametype:a,frame_vcount:1,frame_acount:5,pts:138960,pkt_size:424
packet count:9 ,stream_index:1,packet_vcount:3,packet_acount:6,pts:140880,dts:140880,duration:1920,size:410
frame count:7 ,frametype:a,frame_vcount:1,frame_acount:6,pts:140880,pkt_size:410
packet count:10 ,stream_index:0,packet_vcount:4,packet_acount:6,pts:136800,dts:136800,duration:3600,size:2727
frame count:8 ,frametype:v,frame_vcount:2,frame_acount:6,pts:136800,pkt_size:2727
packet count:11 ,stream_index:0,packet_vcount:5,packet_acount:6,pts:144000,dts:140400,duration:3600,size:2576
frame count:9 ,frametype:v,frame_vcount:3,frame_acount:6,pts:140400,pkt_size:3912
packet count:12 ,stream_index:0,packet_vcount:6,packet_acount:6,pts:162000,dts:144000,duration:3600,size:8391
frame count:10 ,frametype:v,frame_vcount:4,frame_acount:6,pts:144000,pkt_size:2576
packet count:13 ,stream_index:0,packet_vcount:7,packet_acount:6,pts:154800,dts:147600,duration:3600,size:3486
frame count:11 ,frametype:v,frame_vcount:5,frame_acount:6,pts:147600,pkt_size:9433
packet count:14 ,stream_index:1,packet_vcount:7,packet_acount:7,pts:142800,dts:142800,duration:1920,size:388
frame count:12 ,frametype:a,frame_vcount:5,frame_acount:7,pts:142800,pkt_size:388
边栏推荐
- Sophon AutoCV:助力AI工业化生产,实现视觉智能感知
- OpenShift常用管理命令杂记
- 【在优麒麟上使用Electron开发桌面应】
- [utiliser Electron pour développer le Bureau sur youkirin devrait]
- U-Net: Convolutional Networks for Biomedical Images Segmentation
- FCN: Fully Convolutional Networks for Semantic Segmentation
- Star ring technology data security management platform defender heavy release
- Record a case of using WinDbg to analyze memory "leakage"
- 图扑软件数字孪生 | 基于 BIM 技术的可视化管理系统
- Record eval() and no in pytoch_ grad()
猜你喜欢

node_exporter内存使用率不显示

小林coding的内存管理章节

图扑软件数字孪生 | 基于 BIM 技术的可视化管理系统

吴恩达团队2022机器学习课程,来啦

图像分类,看我就够啦!

华夏基金:基金行业数字化转型实践成果分享

Record eval() and no in pytoch_ grad()

ISPRS2020/云检测:Transferring deep learning models for cloud detection between Landsat-8 and Proba-V

Introduction to the development function of Hanlin Youshang system of Hansheng Youpin app
![最大人工岛[如何让一个连通分量的所有节点都记录总节点数?+给连通分量编号]](/img/8b/a60fc36115580f018445e4c2a28a9d.png)
最大人工岛[如何让一个连通分量的所有节点都记录总节点数?+给连通分量编号]
随机推荐
记录Pytorch中的eval()和no_grad()
[paddleclas] common commands
mybash
让更多港澳青年了解南沙特色文创产品!“南沙麒麟”正式亮相
Elk log analysis system
matlab内建函数怎么不同颜色,matlab分段函数不同颜色绘图
Access the database and use redis as the cache of MySQL (a combination of redis and MySQL)
Sophon CE Community Edition is online, and free get is a lightweight, easy-to-use, efficient and intelligent data analysis tool
深拷贝与浅拷贝【面试题3】
如何获取飞机穿过雷达两端的坐标
EasyCVR接入设备开启音频后,视频无法正常播放是什么原因?
ISPRS2020/云检测:Transferring deep learning models for cloud detection between Landsat-8 and Proba-V
Sophon kg upgrade 3.1: break down barriers between data and liberate enterprise productivity
Binder开辟线程数过多导致主线程ANR异常
集群部署如何解决海量视频接入与大并发需求?
VC编程入门浅谈「建议收藏」
南京大学:新时代数字化人才培养方案探讨
Nanjing University: Discussion on the training program of digital talents in the new era
Sophon CE社区版上线,免费Get轻量易用、高效智能的数据分析工具
OpenShift常用管理命令杂记