2014-01-24 122 views
6

我想要使用進度指示將.pptx文件轉換爲.mp4視頻文件。我使用Python 2.7.6,以便在win32com.client模塊一起在Microsoft PowerPoint自動幾個行動2013年Powerpoint視頻導出進度使用ResampleMediaTask

這是我到目前爲止的代碼:

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 

的問題在我情況是,我沒有得到導出到視頻進度的指示。我知道這些信息是可用的,因爲從應用程序內導出到視頻時,Powerpoint本身會顯示確切的進度條。

到目前爲止,我設法檢索的唯一信息是輪詢CreateVideoStatus屬性,該屬性僅告訴我轉換是否已結束。

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

然而,根據這個帖子Powerpoint 2013 - Progress for export to video,用戶Steve Rindsberg表明,我們應該使用ResampleMediaTasks對象及其PercentComplete()方法來獲得進展。

關於如何在Python中實現這一點的任何想法?

回答

1

對於使用ResampleMediaTasks,您需要在Python中創建其COM對象,並使用它來獲取對話期間的進度百分比。一個完整的例子: http://bit.ly/1iUbZKO

正如你可以在第8173行看到的,它轉換PPT文件並使用ResampleMediaTasks來獲取它的進度。 您可以使用該源項目中的整個openlp包或使用它的一部分。 要下載整個項目,您需要安裝BZR客戶端。

+0

我剛剛做了:'powerpoint.ResampleMediaTasks.PercentComplete()'但'PercentComplete()'由於某種原因停留在100%,就像在這篇文章中一樣:http://stackoverflow.com/a/19102209/178728 – kstratis

+0

所以我認爲Microsoft的ResampleMedia ActiveX對象確實有這個問題。 –

相關問題