我编写了一个 python 脚本,使用 pywin32 将 ppt 转换为视频,该脚本工作正常,但是当我尝试在 Ubuntu 环境中导入我的脚本时,pywin32 无法作为其 Windows 支持的模块工作。所以我想找到一些可以在Ubuntu环境中使用python将ppt转换为视频的东西。
这些是在 Windows 中运行良好的脚本。
import win32com.client
import time
import os
ppSaveAsWMV = 37
def cover_ppt_to_wmv(ppt_src,wmv_target):
ppt = win32com.client.Dispatch('PowerPoint.Application')
presentation = ppt.Presentations.Open(ppt_src,WithWindow=False)
presentation.CreateVideo(wmv_target,-1,4,720,24,60)
start_time_stamp = time.time()
while True:
time.sleep(4)
try:
os.rename(wmv_target,wmv_target)
print('success')
break
except Exception:
pass
end_time_stamp=time.time()
print(end_time_stamp-start_time_stamp)
ppt.Quit()
pass
if __name__ == '__main__':
cover_ppt_to_wmv('','')
Run Code Online (Sandbox Code Playgroud)