In generating H.264 and H.265 video with Media Foundation all right, but when I'm tying to use VP90 I got this one in IMFSinkWriter::Finalize():
0xc00d4a45 : Sink could not create valid output file because required headers were not provided to the sink.
Generating the output media type:
MFCreateMediaType(&pMediaTypeOutVideo);
pMediaTypeOutVideo->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
pMediaTypeOutVideo->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_VP90);
MFSetAttributeSize(pMediaTypeOutVideo, MF_MT_FRAME_SIZE, 1920, 1080);
MFSetAttributeRatio(pMediaTypeOutVideo, MF_MT_FRAME_RATE, 30, 1);
MFSetAttributeRatio(pMediaTypeOutVideo, MF_MT_PIXEL_ASPECT_RATIO, 1, 1);
pMediaTypeOutVideo->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive);
// ? pMediaTypeOutVideo->SetUINT32(MF_MT_VIDEO_PROFILE, 1);
// ? Should I set some MF_MT_MPEG_SEQUENCE_HEADER ?
Input type
MFCreateMediaType(&pMediaTypeVideoIn);
pMediaTypeVideoIn->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
pMediaTypeVideoIn->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_NV12);
MFSetAttributeSize(pMediaTypeVideoIn, MF_MT_FRAME_SIZE, 1920, 1080);
MFSetAttributeRatio(pMediaTypeVideoIn, MF_MT_FRAME_RATE, 30, 1);
MFSetAttributeRatio(pMediaTypeVideoIn, MF_MT_PIXEL_ASPECT_RATIO, 1, 1);
The sink accepts the types and encodes indeed. It's just that finalize() fails.
Should I set something MP4 related to the sink? For example somethin from here, here or here. Can I use an alternative container instead of MP4?
Update, it seems I have to set the MP4 sample description box. According to this MSDN article MF will only set it for AVC. I also saw this, this and this but I'm still not sure how to do it.
Update, after saving a vp90 mp4 file with ffmpeg I was able to get the MP4 description as this:
UINT8 bvp90[] = { 0x00,0x00,0x00,0x94,0x73,0x74,0x73,0x64,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x84,0x76,0x70,0x30,0x39,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x80,0x04,0x38,0x00,0x48,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0xFF,0xFF,0x00,0x00,0x00,0x14,0x76,0x70,0x63,0x43,0x01,0x00,0x00,0x00,0x00,0x28,0x80,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x0A,0x66,0x69,0x65,0x6C,0x01,0x00,0x00,0x00,0x00,0x10,0x70,0x61,0x73,0x70,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01 };
Passing this to media foundation with MF_MT_MPEG4_SAMPLE_DESCRIPTION works, but I 'd like to know more about it before using it like that.
Best,