简体   繁体   English

webrtc 对等连接中的音频和视频如何保持同步?

[英]How does audio and video in a webrtc peerconnection stay in sync?

How does audio and video in a webrtc peerconnection stay in sync? webrtc 对等连接中的音频和视频如何保持同步? I am using an API which publishes audio and video (I assume as one peer connection) to a media server.我正在使用 API 将音频和视频(我假设为一个对等连接)发布到媒体服务器。 The audio can occasionally go out of sync up to 200ms.音频有时会出现长达 200 毫秒的不同步 go。 I am attributing this to the possibility that the audio and video are separate streams and this accounts for the why the sync can be out.我将此归因于音频和视频是单独的流的可能性,这解释了为什么会出现同步。

RTP/RTCP (which WebRTC uses) traditionally uses the RTCP Sender Report . RTP/RTCP(WebRTC 使用)传统上使用RTCP Sender Report That allows each SSRC stream to be synced on a NTP Timestamp.这允许每个 SSRC stream 在 NTP 时间戳上同步。 Browsers do use them today, so things should work.浏览器今天确实使用它们,所以应该可以。

Are you doing any protocol bridging or anything that could be RTP only?你在做任何协议桥接或任何可能只是 RTP 的事情吗? What Media Server are you using?您使用的是什么媒体服务器?

In addition to Sean's answer:除了肖恩的回答:

WebRTC player in browsers has a very low tolerance for timestamp difference between arriving audio and video samples.浏览器中的 WebRTC 播放器对到达的音频和视频样本之间的时间戳差异的容忍度非常低。 Your audio and video streams must be aligned (interleaved) precisely, ie the timestamp of last audio sample received from network, should be +- 200ms or so comparing to timestamp of last video frame received from network.您的音频和视频流必须精确对齐(交错),即从网络接收到的最后一个音频样本的时间戳,与从网络接收到的最后一个视频帧的时间戳相比,应该是 +- 200 毫秒左右。 Otherwise WebRTC player will stop using NTP Timestamps and will play streams individually.否则 WebRTC 播放器将停止使用 NTP 时间戳并单独播放流。 This is because WebRTC player tries to keep latency at a minimum.这是因为 WebRTC 播放器试图将延迟保持在最低限度。 Not sure it's good decision from WebRTC team.不确定 WebRTC 团队的决定是否正确。 If your bandwidth is not sufficient, or if live encoder provides streams not timestamp-aligned - then you will have out of sync playback.如果您的带宽不足,或者实时编码器提供的流未与时间戳对齐 - 那么您将无法同步播放。 In my opinion, WebRTC player could have a setting - whether to use that tolerance value or always play in sync, using NTP Timestamps, at the expense of latency.在我看来,WebRTC 播放器可以有一个设置 - 是使用该容差值还是始终同步播放,使用 NTP 时间戳,但以延迟为代价。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 保存通过webrtc peerConnection创建的视频/音频会话 - saving a video/audio session created through webrtc peerConnection 如何在WebRtc中关闭peerConnection - How to close peerConnection in WebRtc WebRTC在同一个peerConnection中有多个视频流 - WebRTC multiple video streams in same peerConnection webRTC如何实现从远程同步其音频和视频流? - How does webRTC implement synchronization of the their audio and video streams from remote? 如何修复 Android/Webrtc/PeerConnection/createOffer 中的“m=video 9 UDP/TLS/RTP/SAVPF 0”问题 - How to fix "m=video 9 UDP/TLS/RTP/SAVPF 0" issus in Android/Webrtc/PeerConnection/createOffer 如何在 peerConnection.CreateAnswer() 中设置 MediaConstraints 以使用 Android 原生的 WebRTC Jar 进行视频通话 - How to set MediaConstraints in peerConnection.CreateAnswer() for Video Calling using WebRTC Jar for Android native 本机WebRTC如何为PeerConnection的DataChannel禁用加密 - Native Webrtc how to disable encryption for DataChannel of PeerConnection 如何在JavaScript中覆盖WebRTC的PeerConnection构造函数 - How to overwrite the PeerConnection constructor of WebRTC in javascript 如何从 WebRTC PeerConnection 获取多个流 - How to get multiple streams from WebRTC PeerConnection 如何正确关闭 iOS 中的 WebRTC peerConnection? - How to properly close WebRTC peerConnection in iOS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM