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?
The export should only take a minute or two, depending on the length, size and complexity of your presentation.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With