tcp - 通过 TCP 使用 RTSP 抓取视频

标签 tcp h.264 rtsp rtp

我想从带有 RTSP 的设备中检索一些视频数据。

基于 UDP 的 RTSP 运行良好,但我需要它基于 TCP。

发出 RTSP 命令后,我收到了 RTP,但我不知道如何在这里处理它们。 有效载荷如下:$[channel - 1 bytes][length - 2bytes][data]

问题是我收到这样的数据包,有时还会收到 channel 为 10 或 99 等的其他数据包。

那么任何人都可以提供一些关于如何处理有效载荷的意见吗?

最佳答案

RFC 2326 "Real Time Streaming Protocol (RTSP)" 中应有尽有.您需要“10.12 嵌入式(交错)二进制数据”:

Stream data such as RTP packets is encapsulated by an ASCII dollar sign (24 hexadecimal), followed by a one-byte channel identifier, followed by the length of the encapsulated binary data as a binary, two-byte integer in network byte order. The stream data follows immediately afterwards, without a CRLF, but including the upper-layer protocol headers. Each $ block contains exactly one upper-layer protocol data unit, e.g., one RTP packet.

还有一个小例子:

 S->C: $\000{2 byte length}{"length" bytes data, w/RTP header}
 S->C: $\000{2 byte length}{"length" bytes data, w/RTP header}
 S->C: $\001{2 byte length}{"length" bytes  RTCP packet}

关于tcp - 通过 TCP 使用 RTSP 抓取视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12110541/

相关文章:

ios - iOS 上允许使用 RTSP 还是必须使用 Http Live Streaming?

c++ - 录制 RTSP 音频流 G.726 无需转码

python - 带有 Python : How to optimize my implementation? 的 TCP 服务器

C# 对象类型转换为 byte[],通过 TCP 发送并转换回 double

c - 在C中设置TCP重传超时

video - 为什么从 avi 容器解码帧并将它们编码为 h264/mp​​4 不起作用?

ios - 在 iOS 上解码编码为 H.264 的单帧

sockets - 如何侵入 Unix 内核以从 TCP 中删除指数退避?

android - 如何使用 MediaCodec 将位图编码为视频?

python - 在 Python 中从 RTSP 流中读取帧