I'm trying to encode audio to an MP4 file with a custom compression codec and my IMFTransform works correctly until SinkWriter's Finalize:
0xc00d4a45 : Sink could not create valid output file because required headers were not provided to the sink.
I'm trying to provide a dummy sample descriptor to no result:
struct SADB
{
unsigned int len = 28;
unsigned int stsd = 0xBBBB;
unsigned int verflag = 0;
unsigned int nume = 1;
unsigned int len1 = 12;
unsigned int cod1 = 0xAAAA;
unsigned int data1 = 0;
};
SADB sadb;
attributes->SetBlob(MF_MT_MPEG4_SAMPLE_DESCRIPTION, (UINT8*)&sadb, sizeof(sadb));
MFCreateSinkWriterFromURL(L"1.mp4", 0, attributes, &wr);
...
audiooutmt->SetBlob(MF_MT_MPEG4_SAMPLE_DESCRIPTION, (UINT8*)&sadb, sizeof(sadb));
wr->AddStream(audiooutmt, &sidx);
I even tried to provide a sample description got from a known mp4 file with AAC compression, still same error.
How can I make the Sink Writer accept my custom audio compression?
Best,
Edit: as I found out, the media type of the stream had erased the mpeg info. Why?
By getting the MF_SOURCE_READER_MEDIASOURCE media source, then the stream, then the media type handler I was able to reinject the mpeg2 type.
Why this weird behaviour occurs?