Convert PPT to video in Java

Render PowerPoint slides to video frames and assemble them into a video file using Java code

Convert PowerPoint to video using Aspose.Slides

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

This PPT to video workflow uses Aspose.Slides to generate presentation frames and the Java ffmpeg wrapper to assemble the frames into a video file.

How to convert PPT to video

  1. Install Aspose.Slides for Java and download ffmpeg .

  2. Add this dependency to your pom.xml file:

    <dependency>
        <groupId>net.bramp.ffmpeg</groupId>
        <artifactId>ffmpeg</artifactId>
        <version>0.7.0</version>
    </dependency>
    

  3. Run the Java PowerPoint to video code.

Convert PowerPoint to video in Java

Use this Java code to convert PPT to video:

Java code for converting PowerPoint to video

Presentation presentation = new Presentation("presentation.ppt");
try {
    final int framesPerSecond = 30;

    PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation);
    try {
        PresentationPlayer presentationPlayer = new PresentationPlayer(animationsGenerator, framesPerSecond);
        try {
            presentationPlayer.setFrameTick((sender, arguments) -> {
                String framePath = String.format("frame_%04d.png", sender.getFrameIndex());
                arguments.getFrame().save(framePath);
            });
            animationsGenerator.run(presentation.getSlides());
        } finally {
            presentationPlayer.dispose();
        }
    } finally {
        animationsGenerator.dispose();
    }

    FFmpeg ffmpeg = new FFmpeg("path/to/ffmpeg");
    FFprobe ffprobe = new FFprobe("path/to/ffprobe");

    FFmpegBuilder builder = new FFmpegBuilder()
            .addExtraArgs("-start_number", "1")
            .setInput("frame_%04d.png")
            .addOutput("output.avi")
            .setVideoFrameRate(FFmpeg.FPS_24)
            .setFormat("avi")
            .done();

    FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);
    executor.createJob(builder).run();
} finally {
    presentation.dispose();
}

Other Supported Conversions

You can also convert PowerPoint to files in other formats