MediaFoundation, bitmap to mp4

I use bitmaps in the form of BYTE arrays that contain the RGB values ​​of each pixel in very similar and interchangeable formats with the microsoft CBitmap class. Therefore, let's look at the fact that I have an array of CBitmaps, and I want to convert them to mp4 with MediaFoundation Transcode Api, as in this example: toMp4 . However, in this example, they are passed from the URL.

 // Use the source resolver to create the media source
  hr = pResolver->CreateObjectFromURL(pszURL, MF_RESOLUTION_MEDIASOURCE, NULL, &ObjectType, &pSource);

In my case, I have bitmaps in memory. Therefore, I believe that I can use this function. IMFSourceResolver :: CreateObjectFromByteStream

I am not sure if this is possible. As a summary, how can I convert CBitmap arrays to mp4 using transcode api?

+4
source share
1 answer

The transcoding API assumes that you have a source and destination for the operation in a specific “format” recognized by the Media Foundation. That is, the source and destination are represented by sources and receivers of the Media Foundation, and then the API covers the process of converting one to another.

This is not your case. Your source does not support Media Foundation.

For your scenario, the corresponding Sink Writer API . It offers a user-friendly interface for transferring Media Media data to the Media Foundation pipeline and creating an encoded video using Media Foundation.

, Sink Writer , .

. : Sink Writer .

+6

Source: https://habr.com/ru/post/1679444/


All Articles