Convert PPTX to Video in C++

Create video from PowerPoint slides using Aspose.Slides for C++ and ffmpeg.

Convert PowerPoint to Video Using Aspose.Slides

Aspose.Slides for C++ can render PowerPoint presentations to image frames. To create a video, render frames with PresentationAnimationsGenerator and PresentationPlayer, then pass those frames to ffmpeg.

How to Convert PPTX to Video

  1. Install Aspose.Slides for C++ from NuGet or the releases page , and install ffmpeg from the ffmpeg download page .

  2. Add ffmpeg.exe to the PATH environment variable.

  3. Run the C++ code to render PPTX frames and create an MP4 video.

Convert PowerPoint to Video in C++

Use this C++ code to convert PPTX to video:

PPTX to Video C++ Conversion Source Code

void SaveFrame(System::SharedPtr<PresentationPlayer> presentationPlayer, System::SharedPtr<FrameTickEventArgs> eventArguments)
{
    auto frameFileName = String::Format(u"frame_{0}.png", presentationPlayer->get_FrameIndex());
    eventArguments->GetFrame()->Save(frameFileName);
}

void Run()
{
    auto presentation = MakeObject<Presentation>(u"presentation.pptx");

    const int framesPerSecond = 33;
    auto animationsGenerator = MakeObject<PresentationAnimationsGenerator>(presentation);
    auto player = MakeObject<PresentationPlayer>(animationsGenerator, framesPerSecond);
    player->FrameTick += SaveFrame;

    animationsGenerator->Run(presentation->get_Slides());

    auto ffmpegParameters = String::Format(
        u"-loglevel {0} -framerate {1} -i {2} -y -c:v {3} -pix_fmt {4} {5}",
        u"warning", framesPerSecond, u"frame_%d.png", u"libx264", u"yuv420p", u"video.mp4");
    auto ffmpegProcess = Process::Start(u"ffmpeg", ffmpegParameters);
    ffmpegProcess->WaitForExit();

    presentation->Dispose();
}

Other Supported Conversions

You can also convert PowerPoint to files in other formats.