English 中文(简体)
如何通过 UDP 发送 MPEGTS 流
原标题:How to send MPEGTS streams over UDP

我正在开发一个实时视频流系统,主要由服务器和几个客户组成。

目前, 让我们忽略软件包是如何在服务器和客户端之间传输的, 让我们只关注 < 坚固> 服务器如何通过 UDP 软件包发送 MPEGTS 流 。

流以 MPEGTS 格式编码。

我想做的是阅读一些包(主要问题是“多少? ” ) 并将其封装在UDP包中。 目的地(一个客户端)读了这些UDP包,然后将其转发给VLC, VLC能够通过阅读 UDP包来播放 MPEGTS 网络流 。

If I send only video packets, everything works fine, instead if I try to encapsulate in the same UDP packet, both some video packets and some audio packets, VLC is not able to decode and play the stream. I read somewhere that each UDP packet should contain 7 TS packets, but unfortunately even if I comply with this rule, VLC doesn t decode the stream correctly.

这是我的程序代码样本:http://pastebin.com/evmi6FkY

<强> 如何将 MPEGTS 包装在 UDP 包中?

谢谢!

问题回答

您的问题是:“让我们忽略软件包是如何在服务器和客户之间传输的 ” 。

UDP要求你处理网络运输的所有问题,包括流量控制、误差检测和回收、路径最大传输单位大小、包装、缓冲、序列化、除重复等。

即使你将数据分解成仅仅正确大小的包,并以正确的速率发送数据,但有些数据仍然会丢失、复制或交付。 您的代码必须处理所有这些条件, 否则您无法相信您收到的是您发送的信息。

在这个特定情况下,我想,你的包已经太大了,导致破碎和高下降率。 一般来说,最好不要每包超过1400字节。 但是,不正确的订购、丢失和重复都是可能的,而且随着你试图发送更多数据,也都更有可能发生。

Dislamenter:我为一家生产商业性UDP数据传输软件的公司工作。

You can try https://github.com/KwikFlixTV/kwik-udp-send It s uses ts or FIFO files and send constant bitrate stream.

重要特征清单:

  • 将 ts 文件作为 ts udp 流发送

  • 如果没有要发送的文件, 它会发送空包

  • 与实时流程/线索优先事项一起工作,以稳定河流

  • 使用 FIFFO 文件

  • 读取文件到缓存缓存文件, 并加一个累积部分, 以稳定流流





相关问题
Failure scenarios for reliable UDP?

What could be good list of failure scenaros for testing a reliable UDP layer? I have thought of the below cases: Drop Data packets Drop ACK, NAK Packets Send packets in out of sequence. Drop intial ...

C windows sendto()

I am trying to send over UDP using the following code, but i m getting strange results. if((sendto(newSocket, sendBuf, totalLength, 0, (SOCKADDR *)&sendAddr, sizeof(sendAddr)) == bytesSent) &...

General sockets UDP programming question

I have an FPGA device with which my code needs to talk. The protocol is as follows: I send a single non-zero byte (UDP) to turn on a feature. The FPGA board then begins spewing data on the port ...

Twisted Spread suitable for multiplayer racing sim?

Do you think that Twisted Spread may be suitable (in terms of performance) for a multiplayer racing simulator? The rest of the application is based on Python-Ogre. Can Perspective Broker run upon (...

Ruby UDP server/client test fails

I am trying to setup a simple UDP client and server using Ruby. The code looks like this: require socket.so class UDPServer def initialize(port) @port = port end def start @socket = ...

Should I use (non-blocking) NIO for UDP?

According to this post, UDP just doesn t block. Are there any advantage using the (non-blocking) NIO API for UDP? Or should I just use the easier "traditional" io API?

Connecting to a Source game server in VB.NET

I m developing an application that detects Source-based games running on the LAN. Following up on the specifications provided by Valve, I have it narrowed down to exactly what I want: making a UDP ...

热门标签