h264 RTP时间戳 [英] h264 RTP timestamp

查看:532
本文介绍了h264 RTP时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对h264 RTP数据包的时间戳感到困惑.我知道视频的挂钟频率为90KHz,这是我在SIP SDP中定义的.我的编码器的帧速率不完全是30 FPS,它是可变的.实时变化范围从15 FPS到30 FPS.因此,我不能使用任何固定的时间戳.

I have a confusion about the timestamp of h264 RTP packet. I know the wall clock rate of video is 90KHz which I defined in the SIP SDP. The frame rate of my encoder is not exactly 30 FPS, it is variable. It varies from 15 FPS to 30 FPS on the fly. So, I cannot use any fixed timestamp.

任何人都可以告诉我以下编码数据包的时间戳.
在0毫秒后,已编码的RTP时间戳= 0(让开始时间戳为0)
经过50毫秒的编码RTP时间戳=?
40毫秒编码后的RTP时间戳=?
经过33毫秒的编码RTP时间戳=?

Could any one tell me the timestamp of the following encoded packet.
After 0 milisecond encoded RTP timestamp = 0 (Let the starting timestamp 0)
After 50 milisecond encoded RTP timestamp = ?
After 40 milisecond encoded RTP timestamp = ?
After 33 milisecond encoded RTP timestamp = ?

编码帧率可变时的公式是什么?

What is the formula when the encoded frame rate is variable?

谢谢.

推荐答案

您的编码器以10FPS或30FPS编码视频都没有关系,使用RTP时间戳,您可以告诉接收器两个帧之间的暂停时间是多长时间.因此,您可以即时确定每个帧.这样,您可以在一秒钟内发送10帧(10fps),而在一秒钟内您可以发送30帧(30 fps).您只需要正确设置RTP时间戳.如果我有您的问题,您会怀疑如何执行此操作...

It doesn't matter if your encoder encodes video at 10FPS or 30FPS, with RTP timestamp you tell the receiver how long is the pause between the two frames. So you determine that on the fly for each frame. That way you can send 10 frames in one second (10fps), and in other second you can send 30 frames (30 fps). You only need to set the RTP timestamp correctly. And if I get your question, you are in doubt how to do this...

让开始时间戳记为0,您将以毫秒为单位的壁钟时间乘以100到最后的RTP时间戳记,或者可以使用任何所需的时间标度.要使解码器以30fps的速度解码10fps的视频,请为每个数据包在RTP时间戳上添加333000 ...但是让我们看一下您的示例:

Let the starting time stamp be 0, you add the wall clock time in milliseconds multiplied by 100 to the last RTP timestamp, or you can use any time scale you want. To make the decoder decode 10fps video at 30fps, add 333000 to RTP timestamp for each packet... but lets look at your example:

Frame #      RTP Time   Time between frames [ms]
[  1]               0   0
[  2]           50000   50
[  3]           90000   40
[  4]          420000   33  

因此,如果像这样(Time in ms * 100000)那样设置RTP时间戳,则将使解码器加载并解码第1帧,然后加载并解码第2帧,但是它将休眠50 ms(第1帧和第2帧之间的时差)在绘制第2帧之前,依此类推...

So if you set RTP timestamp like this (Time in ms * 100000) you will make the decoder load and decode Frame 1, and then load and decode Frame 2, but it will sleep for 50 ms (time difference between Frame 1 and Frame 2) before it draws the Frame 2, and so on...

正如您所看到的,解码器使用RTP时间戳来知道何时显示每个视频,并且它不介意视频是以30或10 fps编码的.

And as you can see, the decoder uses RTP timestamps to know when to display each one, and it doesnt mind if the video was encoded at 30 or 10 fps.

此外,如果视频为30 fps,这并不意味着每秒钟将有30个RTP数据包.有时可能会超过100,因此您将无法确保使用正确的RTP时间戳计算公式.

Also, if the video is 30 fps, that doesnt mean that for each second there will be 30 RTP packets. Sometimes there can be more then 100, so you can not have a formula that ensures the correct RTP timestamp calculation.

我想这就是您所需要的...希望我能帮上忙,如果我不这样做,请不要-1我... =)

I guess that this is what you need... hope I helped, dont -1 me if I didnt... =)

这篇关于h264 RTP时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆