Hiya folks,
I'm creating audio and video and sending it to an IMFSinkWriter to output as an H.264/AAC mp4 movie. I've noticed that after about10800 frames of 640 x 480 resolution video with audio the sink writer basically stops responding.. it becomes so slow that the program is unusable and eventually it crashes.
I thought I fixed the issue by calling IMFSinkWriter->Flush() about every second.. this kept the performance peppy, but then I noticed that the resulting movie was skipping. I wasn't too surprised as it is documented in the Flush() API that when calling Flush, all pending samples are dropped. Ok, fine.
So then I tried calling IMFSinkWriter->NotifyEndOfSegment() about every second. This also kept the performance peppy and didn't seem to drop frames. However, I noticed that it was causing my audio track and video track to get out of sink... specifically, after awhile, the video starts advancing faster than the audio (picture a slideshow, here, where the audio track is correct but the pictures are jumping ahead of their audio). It's like the duration of the video frames is messed up.
I thought perhaps that somehow queued samples were still being dropped so I tried using IMSinkWriter->GetStatistics() to watch for pending samples and wait for them before proceeding, but this hasn't fixed my problem. I'm left with two choices: call Notify() and screw up my synchronization, or don't call Notify() and bog down the sink writer. Either choice is unacceptable.. I must be doing something wrong. Can someone please point me in the right direction? I must be missing something basic and significant in my use of the IMFSinkWriter.