合成SPS和PPS,以获得iOS VideoToolbox的不完整H264流

时间:2019-03-19 13:02:22

标签: ios h.264 video-toolbox

我有一个AXIS IP摄像机(M1054),它可以通过RTSP发送H264 / RTP流。

不幸的是,它们根本不发送SPS和PPS NALU,它们仅传输(分段的)编解码器片。

我正在尝试使用iOS VideoToolbox框架对该流进行解码,该框架需要H264 SPS和PPS元组来正确设置CMFormatDescription

我想知道如何通过查看实际的H264切片来综合必要的参数集吗?

更新:我捕获了一个示例会话,其中mplayer设法通过Wireshark显示流。捕获文件is here,您可以看到整个RTSP设置以及几秒钟的RTP。

1 个答案:

答案 0 :(得分:1)

RTP consists of 3 sets of flows.

  1. RTP for the media
  2. RTSP for controlling the connection
  3. RTCP for the sender confirmation and timestamps.

Although the SPS/PPS is often in band inside the stream and is transported via RTP - it doesn't need to be there (and may be shouldn't be there). The SPS/PPS is transmitted as part of the setup process (RTSP). I usually recommend running http://www.live555.com/ in the debugger to learn about the details of the process - but http://www.live555.com/ is currently down.

In very rare circumstances you could recreate the SPS/PPS from a well known constrained H.264 stream. But in general you can't. So the SPS/PPS are metadata of the H.264 stream that is not redundantly stored anywhere else.

So if your familiarize yourself with the setup process - RTSP - it will be pretty obvious.