VideoToolbox对某些H264编码分辨率的不兼容

ffmpeg中使用VideoToolbox进行解码的过程,如果视频编码的H264分辨率比较怪异,比如300X180或者是320X240这种,反馈一个VideoToolbox session not available

    status = VTDecompressionSessionCreate(NULL,                      // allocator
                                          videotoolbox->cm_fmt_desc, // videoFormatDescription
                                          decoder_spec,              // videoDecoderSpecification
                                          buf_attr,                  // destinationImageBufferAttributes
                                          &decoder_cb,               // outputCallback
                                          &videotoolbox->session);   // decompressionSessionOut
    //session无法获取到值,如果分辨率不是VideoToolbox可以支持的
    if (decoder_spec)
        CFRelease(decoder_spec);
    if (buf_attr)
        CFRelease(buf_attr);

    switch (status) {
    case kVTVideoDecoderNotAvailableNowErr:
        av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox session not available.\n");

实际上这个问题应该VideoToolbox的本身库兼容性问题,然后提示的又不太友好,实际上苹果官方的文档也没有明确的相关说明,算是一个很诡异的问题。

Overview
--------

VideoToolbox is a low-level framework that provides direct access to hardware encoders and decoders. It provides services for video compression and decompression, and for conversion between raster image formats stored in CoreVideo pixel buffers. These services are provided in the form of session objects (compression, decompression, and pixel transfer), which are vended as Core Foundation (CF) types. Apps that don't need direct access to hardware encoders and decoders should not need to use VideoToolbox directly.

你可能感兴趣的:(ffmpeg)