Convert PowerPoint Presentations to Video in Python

Overview

By converting your PowerPoint or OpenDocument presentation to video, you gain:

Increased accessibility: All devices, regardless of platform, are equipped with video players by default, making it easier for users to open or play videos compared to traditional presentation applications.

Wider reach: Videos enable you to reach a larger audience and present information in a more engaging format. Surveys and statistics indicate that people prefer to watch and consume video content over other forms, making your message more impactful.

In Aspose.Slides for Python 24.4, we implemented support for converting presentations to video.

  • Use Aspose.Slides for Python to generate frames from the presentation slides at a specified frame rate (FPS).
  • Then, use a third-party utility like ffmpeg to compile these frames into a video.

Convert a PowerPoint Presentation to Video

  1. Use the pip install command to add Aspose.Slides for Python to your project: pip install Aspose.Slides==24.4.0
  2. Download ffmpeg from here or install it via the package manager.
  3. Make sure that ffmpeg is in the PATH. Otherwise, launch ffmpeg using the full path to the binary (e.g., C:\ffmpeg\ffmpeg.exe on Windows or /opt/ffmpeg/ffmpeg on Linux).
  4. Run the PowerPoint-to-video conversion code.

This Python code demonstrates how to convert a presentation (containing a shape and two animation effects) into a video:

import aspose.slides as slides
import subprocess

with slides.Presentation() as presentation:
    slide = presentation.slides[0]

    smile_shape = slide.shapes.add_auto_shape(slides.ShapeType.SMILEY_FACE, 110, 20, 500, 500)

    effect_in = slide.timeline.main_sequence.add_effect(
        smile_shape,
        slides.animation.EffectType.FLY,
        slides.animation.EffectSubtype.TOP_LEFT,
        slides.animation.EffectTriggerType.AFTER_PREVIOUS)

    effect_out = slide.timeline.main_sequence.add_effect(
        smile_shape,
        slides.animation.EffectType.FLY,
        slides.animation.EffectSubtype.BOTTOM_RIGHT,
        slides.animation.EffectTriggerType.AFTER_PREVIOUS)

    effect_in.timing.duration = 2
    effect_out.preset_class_type = slides.animation.EffectPresetClassType.EXIT

    fps = 33
    with slides.export.PresentationEnumerableFramesGenerator(presentation, fps) as frames_stream:
        for frame_args in frames_stream.enumerate_frames(presentation.slides):
            frame = "frame_{:04d}.png".format(frame_args.frames_generator.frame_index)
            frame_args.get_frame().save(frame)

    cmd_line = ["ffmpeg", "-r", str(fps), "-i", "frame_%04d.png", "-y", "-s", "720x540", "-pix_fmt", "yuv420p",
                "smile.webm"]
    subprocess.call(cmd_line)

Video Effects

When converting a PowerPoint presentation to video using Aspose.Slides for Python, you can apply various video effects to enhance the visual quality of the output. These effects allow you to control the appearance of slides in the final video by adding smooth transitions, animations, and other visual elements. This section explains the available video effect options and shows how to apply them.

Animations and transitions make slideshows more engaging and interesting — and they do the same for videos. Let’s add another slide and transition to the code for the previous presentation:

import aspose.pydrawing as drawing

# Add a smile shape and animate it.
# ...

# Add a new slide and an animated transition.
new_slide = presentation.slides.add_empty_slide(presentation.slides[0].layout_slide)
new_slide.background.type = slides.BackgroundType.OWN_BACKGROUND
new_slide.background.fill_format.fill_type = slides.FillType.SOLID
new_slide.background.fill_format.solid_fill_color.color = drawing.Color.indigo
new_slide.slide_show_transition.type = slides.TransitionType.PUSH

Aspose.Slides for Python also supports text animations. In this example, we animate paragraphs on objects so that they appear one after the other, with a one-second delay between them:

import aspose.slides as slides
import subprocess

with slides.Presentation() as presentation:
    slide = presentation.slides[0]

    # Add text and animations.
    auto_shape = slide.shapes.add_auto_shape(slides.ShapeType.RECTANGLE, 210, 120, 300, 300)
    para1 = slides.Paragraph()
    para1.portions.add(slides.Portion("Aspose.Slides for Python"))
    para2 = slides.Paragraph()
    para2.portions.add(slides.Portion("Convert a PowerPoint presentation with text to video"))

    para3 = slides.Paragraph()
    para3.portions.add(slides.Portion("paragraph by paragraph"))
    auto_shape.text_frame.paragraphs.add(para1)
    auto_shape.text_frame.paragraphs.add(para2)
    auto_shape.text_frame.paragraphs.add(para3)
    auto_shape.text_frame.paragraphs.add(slides.Paragraph())

    effect = slide.timeline.main_sequence.add_effect(
        para1,
        slides.animation.EffectType.APPEAR,
        slides.animation.EffectSubtype.NONE,
        slides.animation.EffectTriggerType.AFTER_PREVIOUS)

    effect2 = slide.timeline.main_sequence.add_effect(
        para2,
        slides.animation.EffectType.APPEAR,
        slides.animation.EffectSubtype.NONE,
        slides.animation.EffectTriggerType.AFTER_PREVIOUS)

    effect3 = slide.timeline.main_sequence.add_effect(
        para3,
        slides.animation.EffectType.APPEAR,
        slides.animation.EffectSubtype.NONE,
        slides.animation.EffectTriggerType.AFTER_PREVIOUS)

    effect4 = slide.timeline.main_sequence.add_effect(
        para3,
        slides.animation.EffectType.APPEAR,
        slides.animation.EffectSubtype.NONE,
        slides.animation.EffectTriggerType.AFTER_PREVIOUS)

    effect.timing.trigger_delay_time = 1
    effect2.timing.trigger_delay_time = 1
    effect3.timing.trigger_delay_time = 1
    effect4.timing.trigger_delay_time = 1

    # Convert frames to video.
    fps = 33
    with slides.export.PresentationEnumerableFramesGenerator(presentation, fps) as frames_stream:
        for frame_args in frames_stream.enumerate_frames(presentation.slides):
            frame = "frame_{:04d}.png".format(frame_args.frames_generator.frame_index)
            frame_args.get_frame().save(frame)

    cmd_line = ["ffmpeg", "-r", str(fps), "-i", "frame_%04d.png", "-y", "-s", "720x540", "-pix_fmt", "yuv420p", "text_animation.webm"]
    subprocess.call(cmd_line)

Video Conversion Classes

To enable PowerPoint to video conversion tasks, Aspose.Slides for Python provides the PresentationEnumerableAnimationsGenerator.

PresentationEnumerableAnimationsGenerator allows you to set the frame size for the video (which will be created later) and the FPS (frames per second) value through its constructor. If you pass an instance of a presentation, its Presentation.SlideSize will be used.

To make all animations in a presentation play at once, use the PresentationEnumerableAnimationsGenerator.enumerate_frames method. This method takes a collection of slides and sequentially returns EnumerableFrameArgs. Then, use EnumerableFrameArgs.get_frame() to obtain each video frame.

import aspose.slides as slides

with slides.Presentation("animated.pptx") as presentation:
    fps = 33
    with slides.export.PresentationEnumerableFramesGenerator(presentation, fps) as frames_stream:
        for frame_args in frames_stream.enumerate_frames(presentation.slides):
            frame_args.get_frame().save(f"frame_{frame_args.frames_generator.frame_index:04d}.png")

Then the generated frames can be compiled into a video. For more details, see the Convert PowerPoint to Video section.

Supported Animations and Effects

When converting a PowerPoint presentation to video using Aspose.Slides for Python, it’s important to understand which animations and effects are supported in the output. Aspose.Slides supports a wide range of common entrance, exit, and emphasis effects such as fade, fly in, zoom, and spin. However, some advanced or custom animations may not be fully preserved or may appear differently in the final video. This section outlines the supported animations and effects.

Entrance:

Animation Type Aspose.Slides PowerPoint
Appear not supported supported
Fade supported supported
Fly In supported supported
Float In supported supported
Split supported supported
Wipe supported supported
Shape supported supported
Wheel supported supported
Random Bars supported supported
Grow & Turn not supported supported
Zoom supported supported
Swivel supported supported
Bounce supported supported

Emphasis:

Animation Type Aspose.Slides PowerPoint
Pulse not supported supported
Color Pulse not supported supported
Teeter supported supported
Spin supported supported
Grow/Shrink not supported supported
Desaturate not supported supported
Darken not supported supported
Lighten not supported supported
Transparency not supported supported
Object Color not supported supported
Complementary Color not supported supported
Line Color not supported supported
Fill Color not supported supported

Exit:

Animation Type Aspose.Slides PowerPoint
Disappear not supported supported
Fade supported supported
Fly Out supported supported
Float Out supported supported
Split supported supported
Wipe supported supported
Shape supported supported
Random Bars supported supported
Shrink & Turn not supported supported
Zoom supported supported
Swivel supported supported
Bounce supported supported

Motion Paths:

Animation Type Aspose.Slides PowerPoint
Lines supported supported
Arcs supported supported
Turns supported supported
Shapes supported supported
Loops supported supported
Custom Path supported supported

Supported Slide Transition Effects

Slide transition effects play an important role in creating smooth and visually appealing changes between slides in a video. Aspose.Slides for Python supports a variety of commonly used transition effects to help preserve the flow and style of your original presentation. This section highlights which transition effects are supported during the conversion process.

Subtle:

Animation Type Aspose.Slides PowerPoint
Morph not supported supported
Fade supported supported
Push supported supported
Pull supported supported
Wipe supported supported
Split supported supported
Reveal not supported supported
Random Bars supported supported
Shape not supported supported
Uncover not supported supported
Cover supported supported
Flash supported supported
Strips supported supported

Exciting:

Animation Type Aspose.Slides PowerPoint
Fall Over not supported supported
Drape not supported supported
Curtains not supported supported
Wind not supported supported
Prestige not supported supported
Fracture not supported supported
Crush not supported supported
Peel Off not supported supported
Page Curl not supported supported
Airplane not supported supported
Origami not supported supported
Dissolve supported supported
Checkerboard not supported supported
Blinds not supported supported
Clock supported supported
Ripple not supported supported
Honeycomb not supported supported
Glitter not supported supported
Vortex not supported supported
Shred not supported supported
Switch not supported supported
Flip not supported supported
Gallery not supported supported
Cube not supported supported
Doors not supported supported
Box not supported supported
Comb not supported supported
Zoom supported supported
Random not supported supported

Dynamic Content:

Animation Type Aspose.Slides PowerPoint
Pan not supported supported
Ferris Wheel supported supported
Conveyor not supported supported
Rotate not supported supported
Orbit not supported supported
Fly Through supported supported

FAQs

Is it possible to convert presentations that are password protected?

Yes, Aspose.Slides for Python allows working with password-protected presentations. When processing such files, you need to provide the correct password so that the library can access the content of the presentation.

Does Aspose.Slides for Python support usage in cloud solutions?

Yes, Aspose.Slides for Python can be integrated into cloud applications and services. The library is designed to work in server environments, ensuring high performance and scalability for batch processing of files.

Are there any size limitations for presentations during conversion?

Aspose.Slides for Python is capable of handling presentations of virtually any size. However, when working with very large files, additional system resources may be required, and it is sometimes recommended to optimize the presentation to improve performance.