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
- Use the pip install command to add Aspose.Slides for Python to your project:
pip install Aspose.Slides==24.4.0
- Download ffmpeg from here or install it via the package manager.
- 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). - 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 | ![]() |
![]() |
Fade | ![]() |
![]() |
Fly In | ![]() |
![]() |
Float In | ![]() |
![]() |
Split | ![]() |
![]() |
Wipe | ![]() |
![]() |
Shape | ![]() |
![]() |
Wheel | ![]() |
![]() |
Random Bars | ![]() |
![]() |
Grow & Turn | ![]() |
![]() |
Zoom | ![]() |
![]() |
Swivel | ![]() |
![]() |
Bounce | ![]() |
![]() |
Emphasis:
Animation Type | Aspose.Slides | PowerPoint |
---|---|---|
Pulse | ![]() |
![]() |
Color Pulse | ![]() |
![]() |
Teeter | ![]() |
![]() |
Spin | ![]() |
![]() |
Grow/Shrink | ![]() |
![]() |
Desaturate | ![]() |
![]() |
Darken | ![]() |
![]() |
Lighten | ![]() |
![]() |
Transparency | ![]() |
![]() |
Object Color | ![]() |
![]() |
Complementary Color | ![]() |
![]() |
Line Color | ![]() |
![]() |
Fill Color | ![]() |
![]() |
Exit:
Animation Type | Aspose.Slides | PowerPoint |
---|---|---|
Disappear | ![]() |
![]() |
Fade | ![]() |
![]() |
Fly Out | ![]() |
![]() |
Float Out | ![]() |
![]() |
Split | ![]() |
![]() |
Wipe | ![]() |
![]() |
Shape | ![]() |
![]() |
Random Bars | ![]() |
![]() |
Shrink & Turn | ![]() |
![]() |
Zoom | ![]() |
![]() |
Swivel | ![]() |
![]() |
Bounce | ![]() |
![]() |
Motion Paths:
Animation Type | Aspose.Slides | PowerPoint |
---|---|---|
Lines | ![]() |
![]() |
Arcs | ![]() |
![]() |
Turns | ![]() |
![]() |
Shapes | ![]() |
![]() |
Loops | ![]() |
![]() |
Custom Path | ![]() |
![]() |
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 | ![]() |
![]() |
Fade | ![]() |
![]() |
Push | ![]() |
![]() |
Pull | ![]() |
![]() |
Wipe | ![]() |
![]() |
Split | ![]() |
![]() |
Reveal | ![]() |
![]() |
Random Bars | ![]() |
![]() |
Shape | ![]() |
![]() |
Uncover | ![]() |
![]() |
Cover | ![]() |
![]() |
Flash | ![]() |
![]() |
Strips | ![]() |
![]() |
Exciting:
Animation Type | Aspose.Slides | PowerPoint |
---|---|---|
Fall Over | ![]() |
![]() |
Drape | ![]() |
![]() |
Curtains | ![]() |
![]() |
Wind | ![]() |
![]() |
Prestige | ![]() |
![]() |
Fracture | ![]() |
![]() |
Crush | ![]() |
![]() |
Peel Off | ![]() |
![]() |
Page Curl | ![]() |
![]() |
Airplane | ![]() |
![]() |
Origami | ![]() |
![]() |
Dissolve | ![]() |
![]() |
Checkerboard | ![]() |
![]() |
Blinds | ![]() |
![]() |
Clock | ![]() |
![]() |
Ripple | ![]() |
![]() |
Honeycomb | ![]() |
![]() |
Glitter | ![]() |
![]() |
Vortex | ![]() |
![]() |
Shred | ![]() |
![]() |
Switch | ![]() |
![]() |
Flip | ![]() |
![]() |
Gallery | ![]() |
![]() |
Cube | ![]() |
![]() |
Doors | ![]() |
![]() |
Box | ![]() |
![]() |
Comb | ![]() |
![]() |
Zoom | ![]() |
![]() |
Random | ![]() |
![]() |
Dynamic Content:
Animation Type | Aspose.Slides | PowerPoint |
---|---|---|
Pan | ![]() |
![]() |
Ferris Wheel | ![]() |
![]() |
Conveyor | ![]() |
![]() |
Rotate | ![]() |
![]() |
Orbit | ![]() |
![]() |
Fly Through | ![]() |
![]() |
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.