1

I'm making an iOS app that decodes an h264 stream using video-toolbox. I create the stream with ffmpeg on a PC and send it to an iPhone using RTP. It's working nicely when I use this command to create it:

ffmpeg -y -f:v rawvideo -c:v rawvideo -s 1280x720 -pix_fmt bgra -r 30 -an -i - -pix_fmt yuv420p -c:v libx264 -tune zerolatency -preset fast -b:v 5M -refs 1 -g 30 -profile:v high -level 4.1 -f rtp rtp://192.168.1.100:5678

The iPhone receives and displays all the frames. However, when I enable intra-refresh

-intra-refresh 1

decoding fails with error code -12909 (-8969 on simulator) when VTDecompressionSessionDecodeFrame() is called.

I take care of processing UDP packets to extract NAL Units, so I triple checked this process and discarded a problem with this part of the code.

I didn't find any info about Video-toolbox not supporting intra-refresh, so the question is, does Video-toolbox support intra-refresh? and if it does, am I missing something in the ffmpeg side that makes the stream not supported by Video-toolbox? Do I have to add something to the CMVideoFormatDescriptionRef apart from creating it with SPS and PPS data using CMVideoFormatDescriptionCreateFromH264ParameterSets()?

4

1 回答 1

1
  1. 是的,视频工具箱支持内部刷新
  2. 不,与ffmpeg无关
  3. 不,不需要做任何特别的事情CMVideoFormatDescriptionRef

我想通了,VTDecompressionSession每次收到 SPS 和 PPS NALU 时,我都会创建一个新的,因此解码器会丢失上下文。

它在没有内部刷新的情况下工作,因为在这种情况下,在 SPS 和 PPS 之后立即接收到完整的 I 帧,因此它不需要来自先前帧的上下文。

启用帧内刷新后,只有第一帧是完整的 I 帧,然后解码器依赖于先前帧的上下文,并且必须使用相同的VTDecompressionSession.

于 2018-01-02T14:29:04.577 回答