This quick tutorial shares details to extract media from PowerPoint using Python. All the necessary areas are covered like IDE setting, a list of steps, and a sample code showing how to extract a video from PowerPoint using Python. The given sample code will assist in fetching both the video and audio contents from the presentation.
Steps to Extract Video from PowerPoint using Python
- Set the IDE to use Aspose.Slides for Python via .NET for extracting video
- Import the OS module and Aspose.Slides library
- Define a mapping for fetching the file extension from the content type
- Load the source PPTX file in the Presentation class object
- Parse through all the slides in the presentation
- Inspect all the shapes for embedded media content in each slide
- Check if the shape is a VideoFrame, save it with the appropriate extension using the mapping with the content type
- Check if the shape is an AudioFrame, save it with the appropriate extension using the mapping with the content type
These steps explain how to extract a video from PowerPoint using Python. Load the presentation, iterate through all the slides, fetch each shape and inspect it for the content type. If it is a video or audio, define its extension and save it on the disk.
Code to Extract Audio from PPTX using Python
This code demonstrates how to extract a video from a PowerPoint using Python , or an audio file if one is found. You may use the Presentation.videos or Presentation.audios collection to directly access the content at the presentation level to avoid parsing each slide and shape. Shape.name can also be used to name a file instead of general counters.
This guide has explained how to fetch video and audio content from a presentation. To extract text from a presentation, refer to the article Extract text from PowerPoint using Python.