Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powerpoint video export progress using ResampleMediaTask

I am trying to turn a .pptx file into an .mp4 video file using progress indication. I am using Python 2.7.6 along with the win32com.client module in order to automate a couple of actions in Microsoft Powerpoint 2013.

This is my code so far:

import win32com.client

powerpoint = win32com.client.Dispatch("Powerpoint.Application")
presentation = powerpoint.Presentations.Open(FileName='myFile.pptx',
                                           WithWindow=False)

try:
    # May need a few other parameters as well
    presentation.CreateVideo('out.wmv')
except:
    raise SystemExit

The problem in my case is that I get no indication of the exporting-to-video progress. I know that this information is available because Powerpoint itself shows an exact progress bar when exporting to video from within the application.

The only info I have managed to retrieve so far is by polling the CreateVideoStatus attribute which only tells me if the conversion has ended or not.

while presentation.CreateVideoStatus == 1:
    time.sleep(1) 

However, according to this post Powerpoint 2013 - Progress for export to video, user Steve Rindsberg suggests we should use the ResampleMediaTasks object and its PercentComplete() method to get the progress.

Any ideas on how I could achieve this in Python?

like image 208
stratis Avatar asked Jan 24 '14 11:01

stratis


People also ask

How long does a PowerPoint video take to Export?

The export should only take a minute or two, depending on the length, size and complexity of your presentation.

Why can't I Export a video from PowerPoint?

Disable background programs. If other programs running in the background are causing conflicts with PowerPoint blocking the video export feature, you can fix the problem by disabling all of these programs and processes. This includes your antivirus as well.

How long does it take to Export MP4 from PowerPoint?

This process can take up to 2 or 3 hours to render depending on the size of your Powerpoint, how much audio is in it and the speed of your computer.


1 Answers

For using ResampleMediaTasks you need to create its COM object in Python and use it to get percentage of progress during conversation. A full example: http://bit.ly/1iUbZKO

As you can see in line 8173, it converts PPT files and uses ResampleMediaTasks to get progress of it. You can use whole openlp package from that source project or use parts of it. For downloading whole project you need to install BZR client.

like image 119
72DFBF5B A0DF5BE9 Avatar answered Oct 03 '22 08:10

72DFBF5B A0DF5BE9