Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMVideoFormatDescriptionCreateFromH264ParameterSets issues

Tags:

ios

h.264

ios8

I've tried creating CMVideoFormatDescriptionRef with CMVideoFormatDescriptionCreateFromH264ParameterSets but it fails with -12712 error (which does not seem to be defined in any header)

I've taken my SPS and PPS from an avcC atom of a mov file (created by an iPhone camera app):

61 76 63 43 01 64 00 29 FF E1 00 10 67 64 00 29 AC 56 80 78 02 27 E5 9A 80
80 80 81 01 00 05 28 EE 04 F2 C0

SPS seems to be: 67 64 00 29 AC 56 80 78 02 27 E5 9A 80 80 80 81

...and the PPS: 28 EE 04 F2 C0

I've preceeded SPS and PPS with their 4-byte lengths (tried also 1-byte and 2-byte lenghts with the same results) and issued the call like that:

uint8_t sps[] = {0x00, 0x00, 0x00, 0x10, 0x67, 0x64, 0x00, 0x29, 0xAC, 0x56, 0x80, 0x78, 0x02, 0x27, 0xE5, 0x9A, 0x80, 0x80, 0x80, 0x81};

uint8_t pps[] = {0x00, 0x00, 0x00, 0x05, 0x28, 0xEE, 0x04, 0xF2, 0xC0};

uint8_t* props[] = {sps, pps};

size_t sizes[] = {0x14, 0x09}; // sizes include the 4-byte length

CMVideoFormatDescriptionRef formatDesc;

OSStatus formatCreateResult = CMVideoFormatDescriptionCreateFromH264ParameterSets(NULL, 2, props, sizes, 4, &formatDesc);

I get -12712 as the result every single time (tried SPS / PPS from several files and streams).

Do you have any idea what do I do wrong ? (The code was checked on Xcode6-Beta4 on Simulator). I'd prefer to avoid parsing SPS and PPS on my own and using plain CMVideoFormatDescriptionCreate :-)

like image 649
ZukGnojak Avatar asked Aug 01 '14 10:08

ZukGnojak


1 Answers

Do not include the 4 byte size. Either in the sps/pps payloads, nor the size values.

like image 92
szatmary Avatar answered Oct 05 '22 05:10

szatmary