Retrieving movie codec under iOS?

前端 未结 4 1799
别那么骄傲
别那么骄傲 2020-12-31 21:18

I am trying to find the codec used to compress a movie. I am sure if I need to somehow use CMFormatDescription and get a CMVideoCodecType key. I am stuck as to how to get pa

4条回答
  •  星月不相逢
    2020-12-31 22:16

    A slightly more readable version of @jbat100's answer (for those who were as confused as I was with that #define FourCC2Str, hah)

    // Get your format description from whichever track you want
    CMFormatDescriptionRef formatHint;
    
    // Get the codec and correct endianness
    CMVideoCodecType formatCodec = CFSwapInt32BigToHost(CMFormatDescriptionGetMediaSubType(formatHint));
    
    // add 1 for null terminator
    char formatCodecBuf[sizeof(CMVideoCodecType) + 1] = {0};
    memcpy(formatCodecBuf, &formatCodec, sizeof(CMVideoCodecType));
    
    NSString *formatCodecString = @(formatCodecBuf);
    

提交回复
热议问题