When trying to use the SinkWriter for multiple audio streams:
for (int i = 0; i < alternatives; i++)
{
DWORD ni = 0;
CComPtr<IMFMediaType> co;
MFCreateMediaType(&co);
pMediaTypeOutAudio->CopyAllItems(co);
hr = pSinkWriter->AddStream(co, &ni);
if (FAILED(hr)) return false;
AlternativeOutAudioStreamIndex.push_back(ni);
}
Success.
Later on:
hr = pSinkWriter->WriteSample(wheretowrite, pAudioSample);
where wheretowrite
is the index of the output stream, in a loop to write all audio. Calls succeed.
The resulting mp4 file’s media info shows this for the second audio stream: Errors : Missing ID_END
.
Where, for the first audio stream, it shows correctly mdhd_Duration : 29931
.
What am I missing? The SinkWriter’s Finalize() method also succeeds. No error logs.