the h264 plays faster than it should be.

mc 4,616 Reputation points
2024-08-25T15:59:26.7+00:00

I am using IMFTransform to capture desktop to H264 file.

but it plays very fast.

why?

then I use SinkWriter to write . I tried:

  1. NV12 to H264 succeeded write but still very fast.
  2. RGB to H264 (input mediaType is B8G8R8A8 output media Type is h264) failed.
  3. RGB to WMV (input mediaType is B8G8R8A8 output MediaType is MFVideoFormatWMV3) failed . I think the input format is not right?

please tell how to play normal.

I have set the sampleTime and Duration of IMFSample.

and please tell me how to write WMV type.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,653 questions
0 comments No comments
{count} votes

Accepted answer
  1. Tong Xu - MSFT 2,471 Reputation points Microsoft Vendor
    2024-08-26T07:07:18.9166667+00:00

    Are you following this sample? Tutorial: Using the Sink Writer to Encode Video, just rtStart += rtDuration is wrong. You cannot capture and write screen exactly at this time.

    You must know it to adjust the correct FPS to the encoder. But you also will need to WriteSample at the right time.

    So the solution is using IMFPresentationClock to handle the correct WriteSample time.
    https://github.com/tomrsae/Windows-Screen-Recorder/blob/master/Screen%20Recorder/MP4File.h


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.