Convert PPT to video

When you convert PowerPoint to video, you get increased accessibility and a bigger audience for your presentation or content. The MP4 video format is an incredibly popular file format, so more people will find it easier to open or play your video compared to a PPT file. Furthermore, most people watch and consume video more than other forms of content so your video is likely to get a bigger audience compared to a presentation.

PowerPoint to Video in Java

By the time you finish reading this article, you will have learned how to convert PowerPoint to video in Java.

Java APIs to Convert PPT to Video

Create video in PowerPoint

To convert a PowerPoint presentation to a video programmatically, you need:

  • An API to generate a set of frames from the presentation slides. We recommend Aspose.Slides for Java. Aspose.Slides for Java for is a popular API for creating, editing, converting, and manipulating PowerPoint presentations (without Microsoft PowerPoint or Office). To install Aspose.Slides for Java, see Installation.
  • And another API to create a video based on the generated frames. We recommend ffmpeg (for Java).

Info: Aspose developed a free PowerPoint to video converter that allows you to create stunning videos from presentations. This converter is essentially a live implementation of the PowerPoint to video conversion process.

Convert PPT to Video in Java

  1. Add this to your POM file:
   <dependency>
     <groupId>net.bramp.ffmpeg</groupId>
     <artifactId>ffmpeg</artifactId>
     <version>0.7.0</version>
   </dependency>
  1. Download ffmpeg here.

  2. Run the PowerPoint to video Java code.

This Java code shows you how to convert PPT to video:

Presentation presentation = new Presentation();
try {
// Adds a smile shape and then animates it
IAutoShape smile = presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.SmileyFace, 110, 20, 500, 500);
ISequence mainSequence = presentation.getSlides().get_Item(0).getTimeline().getMainSequence();
IEffect effectIn = mainSequence.addEffect(smile, EffectType.Fly, EffectSubtype.TopLeft, EffectTriggerType.AfterPrevious);
IEffect effectOut = mainSequence.addEffect(smile, EffectType.Fly, EffectSubtype.BottomRight, EffectTriggerType.AfterPrevious);
effectIn.getTiming().setDuration(2f);
effectOut.setPresetClassType(EffectPresetClassType.Exit);
final int fps = 33;
ArrayList<String> frames = new ArrayList<String>();
PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation);
try
{
PresentationPlayer player = new PresentationPlayer(animationsGenerator, fps);
try {
player.setFrameTick((sender, arguments) ->
{
try {
String frame = String.format("frame_%04d.png", sender.getFrameIndex());
ImageIO.write(arguments.getFrame(), "PNG", new java.io.File(frame));
frames.add(frame);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
animationsGenerator.run(presentation.getSlides());
} finally {
if (player != null) player.dispose();
}
} finally {
if (animationsGenerator != null) animationsGenerator.dispose();
}
// Configure ffmpeg binaries folder. See this page: https://github.com/rosenbjerg/FFMpegCore#installation
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();
} catch (IOException e) {
e.printStackTrace();
}

Apply Effects and Animations in Video

PowerPoint allows you to apply animations to the contents of your presentations and also use transitions between slides. Those effects make a presentation (especially in the form of a slideshow) more engaging and interesting. When you convert a PowerPoint presentation to video, it makes sense to use similar effects in the resulting video and Aspose.Slides allows you to do precisely that.

To demonstrate the use of effects and animations in a video, let’s add another slide and transition to the code for the presentation in the previous section this way:

// Adds a smile shape and animates it
// ...
// Adds a new slide and animated transition
ISlide newSlide = presentation.getSlides().addEmptySlide(presentation.getSlides().get_Item(0).getLayoutSlide());
newSlide.getBackground().setType(BackgroundType.OwnBackground);
newSlide.getBackground().getFillFormat().setFillType(FillType.Solid);
newSlide.getBackground().getFillFormat().getSolidFillColor().setColor(Color.MAGENTA);
newSlide.getSlideShowTransition().setType(TransitionType.Push);

Then we animate paragraphs on objects to make those objects appear one after the other (with the delay between appearances set to a second):

Presentation presentation = new Presentation();
try {
// Adds text and animations
IAutoShape autoShape = presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 210, 120, 300, 300);
Paragraph para1 = new Paragraph();
para1.getPortions().add(new Portion("Aspose Slides for Java"));
Paragraph para2 = new Paragraph();
para2.getPortions().add(new Portion("convert PowerPoint Presentation with text to video"));
Paragraph para3 = new Paragraph();
para3.getPortions().add(new Portion("paragraph by paragraph"));
IParagraphCollection paragraphCollection = autoShape.getTextFrame().getParagraphs();
paragraphCollection.add(para1);
paragraphCollection.add(para2);
paragraphCollection.add(para3);
paragraphCollection.add(new Paragraph());
ISequence mainSequence = presentation.getSlides().get_Item(0).getTimeline().getMainSequence();
IEffect effect1 = mainSequence.addEffect(para1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
IEffect effect2 = mainSequence.addEffect(para2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
IEffect effect3 = mainSequence.addEffect(para3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
IEffect effect4 = mainSequence.addEffect(para3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
effect1.getTiming().setTriggerDelayTime(1f);
effect2.getTiming().setTriggerDelayTime(1f);
effect3.getTiming().setTriggerDelayTime(1f);
effect4.getTiming().setTriggerDelayTime(1f);
final int fps = 33;
ArrayList<String> frames = new ArrayList<String>();
PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation);
try
{
PresentationPlayer player = new PresentationPlayer(animationsGenerator, fps);
try {
player.setFrameTick((sender, arguments) ->
{
try {
String frame = String.format("frame_%04d.png", sender.getFrameIndex());
ImageIO.write(arguments.getFrame(), "PNG", new java.io.File(frame));
frames.add(frame);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
animationsGenerator.run(presentation.getSlides());
} finally {
if (player != null) player.dispose();
}
} finally {
if (animationsGenerator != null) animationsGenerator.dispose();
}
// Configure ffmpeg binaries folder. See this page: https://github.com/rosenbjerg/FFMpegCore#installation
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();
} catch (IOException e) {
e.printStackTrace();
}

Get a Free License

If you are looking to try Aspose.Slides features without limitations, we recommend you get a free temporary license.

Conclusion

We believe you now know how to convert PPT to video and also apply animations, transitions, and other effects in your work.

To learn more about Aspose.Slides features, see our documentation. If you have questions, you can post them on our forum.

See Also