直播(Socket)-如何同步音频和视频?
1- 哪一种更适合用于流媒体视频? TCP 或 UDP 套接字以及为什么?
2-直播时,音频和视频分别来自服务器,那么如何确保我显示的视频和设备上播放的音频同步?
1- Which one is better to use for streaming video ? TCP or UDP socket and why?
2- While streaming live, audio and video are coming from the server separately, so how can i make sure that the video i display and the audio I play on the device are in sync?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不久前编写了一个语音聊天应用程序,TCP 是不可能的,如果您正在寻找近实时数据流,UDP 多播实际上是唯一的方法。不过,通过 UDP 进行流传输有两个主要问题:
I wrote a voice chat application a while ago and TCP was out of the question, UDP multicasting is really the only way to go if you're looking for near-realtime data flow. There's two main issues with streaming stuff over UDP though:
我会做UDP。然而,这取决于你想要什么。 UDP 将丢弃数据包而不是等待 (TCP)。权衡在于您是否想要一种稳定但有时缓慢且成本高昂的产品,或者一种高效但有时可能无法交付的产品。当涉及到如何实现它以及如何使用它时,选择权在您手中。
I would do UDP. However it depends on what you want. UDP will drop packets rather than wait (TCP). The trade off is whether you want a stable, but sometimes slow and costly, or one that is efficient, but sometimes may not get delivered. The choice is yours when it comes to how you want to implement it and how you are using it.
如今,甚至 YouTube 也通过 HTTP 进行流传输...这是一个 Nodejs 应用程序,它将文件流式传输到浏览器客户端...用作实时流视频与音频完美同步的起点
Today even youtube streams over HTTP ... here is a nodejs app which streams a file to the browser client ... use as a starting point to live stream video with audio nicely in sync