H.264 实时流媒体、NAL 单位时间戳?
我正在尝试构建一个实时流式传输 Android 手机捕获的视频和音频的系统。使用MediaRecorder在android端捕获视频和auido,然后直接推送到用python编写的服务器。客户应该使用他们的浏览器访问此实时源,因此我使用 Flash 实现了系统的流媒体部分。现在,视频和音频内容都出现在客户端,但问题是它们不同步。我确定这是由闪存中错误的时间戳值引起的(目前我将视频帧的 ts 增加 60 毫秒,但显然该值应该是可变的)。
音频在android手机上被编码成amr,所以我确切地知道amr的每一帧是20ms。然而,视频的情况并非如此,视频被编码为 H.264。为了将它们同步在一起,我必须确切地知道 H.264 的每个帧持续多少毫秒,以便稍后在使用 Flash 传送内容时可以为它们添加时间戳。我的问题是 H.264 的 NAL 单元中是否提供此类信息?我试图在 H.264 标准中寻找答案,但那里的信息实在是太多了。
有人可以指出我正确的方向吗?谢谢。
I'm trying to build a system that live-streams video and audio captured by android phones. Video and auido are captured on the android side using MediaRecorder, and then pushed directly to a server written in python. Clients should access this live feed using their browser, so the I implemented the streaming part of the system using flash. Right now both video and audio content appear on the client side, but the problem is that they are out of sync. I'm sure this is caused by wrong timestamp values in flash (currently I increment ts by 60ms for a frame of video, but clearly this value should be variable).
The audio is encoded into amr on the android phone, so I know exactly each frame of amr is 20ms. However, this is not the case with video, which is encoded into H.264. To synchronized them together, I would have to know exactly how many millisecs each frame of H.264 lasts, so that I can timestamp them later when delivering content using flash. My question is is this kind of information available in NAL units of H.264? I tried to find the answer in H.264 standard, but the information there is just overwhelming.
Can someone please point me at the right direction? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
时间戳不是 NAL 单位,但通常是 RT P。 RTP/RTCP 还负责媒体同步。
您可能还对 H.264 的 RTP 有效负载格式感兴趣。
如果您不使用 RTP,您是否只是通过网络发送原始数据单元?
Timestamps are not in NAL units, but are typically part of RTP. RTP/RTCP also takes care of media synchronisation.
The RTP payload format for H.264 might also be of interest to you.
If you are not using RTP, are you just sending raw data units over the network?