Set up IWMWriter to wirte 4K video

206 Views Asked by At

This question is about using Window Media API to output a 4K WMV video (although theoretically WMV doesn't support output to 4K)

After IWMWriter->BeginWriting() is called on both 32bit and 64bit Win10 (on both systems BeginWriting() returns S_OK), program takes about 450MB memory.

After that I start to use IWMWriter->AllocateSample() to allocate sample buffer and write it to sink using IWMWriter->WriteSample().

On 64bit Win10, conversion can finish gracefully but on 32bit Win10, WriteSample() fails with "out of memory" error after several frames are written.

The only difference I can see on 2 systems is: before calling BeginWriting(), 64Win10 takes 110 MB memory so after BeginWriting() is called, 110+450 is used. On 32bit Win10, 150 MB is used before BeginWriting() so after that 150+450 is used.

The peak working set of the failed conversion is only 761MB, anyone know why in this case WriteSample() returns out of memory. Is there any workaround for this?

== Update: =============================================

The source video contains both video and audio, in the failed case the program writes both video and audio and failed to write video.

If I take audio track out of the file so it only contains video, then conversion can finish gracefully. The peak working set is 716MB.

1

There are 1 best solutions below

4
On

It's about video encoder's memory requirements: at this resolution the application does not fit standard 2 GB of address space of a 32-bit application. You might want to link with /LARGEADDRESSAWARE to bypass out of memory condition.