Correcting live IMFMediaSource time stamps

1

I have two cameras, listed below, that I am trying to use in a Media Foundation topology. Here is a summary of my topology:

Webcam --> MJPG Decoder --> Custom MFT --> H264 Encoder --> MP4 File Sink

The problem with this is that the generated MP4 file has incorrect duration and time scale tags, both for the MP4 container and the H264 stream. I can easily correct this with a tool like MP4Box or YAMB, but my eventual goal is to stream the video.

One potential cause I have identified is that the samples generated by the camera sources do not start at time 0. According to bullet #2 in http://msdn.microsoft.com/en-us/library/windows/desktop/ms700134(v=vs.85).aspx#live_sources, timestamps of a live source should start at 0.

Along this line, I've tried the following to "correct" the sample timestamps:

  1. Re-based the sample time in my custom MFT, using IMFSample::SetSampleTime.
  2. Created a wrapper for the IMFMediaSource and IMFMediaStream objects, which catches and corrects the time stamps associated with the MEMediaSample and MEStreamTick events.

In both of these cases, the media session throws an error 0xC00D4A44 (MF_E_SINK_NO_SAMPLES_PROCESSED), and the resulting MP4 file ends abruptly after the "mdat" atom declaration.


Cameras

  • Logitech BCC950 ConferenceCam
  • Thinkpad W520 Integrated Camera

Systems used (both have same issue):

  • Windows 7 Professional x64
  • Windows 8 x86

Questions:

  1. Is there some other cause I have overlooked for incorrect video duration/time scale?
  2. If not, is there a correct approach for how to re-base sample timestamps?
c++
windows
winapi
video
ms-media-foundation
asked on Stack Overflow May 8, 2013 by mrtumnus • edited May 8, 2013 by mrtumnus

1 Answer

1

Try to reset for every sample flag MFSampleExtension_Discontinuity

pSample->SetUINT32( MFSampleExtension_Discontinuity, FALSE );
answered on Stack Overflow May 17, 2013 by Survarium

User contributions licensed under CC BY-SA 3.0