我必须使用python库在ppt中插入一个视频。此外,我还添加了以下代码来插入它:
from pptx import Presentation
from pptx.util import Inches
prs = Presentation('template.pptx')
filepath = "file2.pptx"
layout = prs.slide_layouts[0]
slide = prs.slides.add_slide(layout9)
path = 'video.mp4'
movie=slide.shapes.add_movie(path
, Inches(4.51), Inches(1.53), Inches(6.98),
Inches(4.69),poster_frame_image=None,mime_type='video/unknown'
)
prs.save(filepath)此代码成功创建视频形状。它显示一个大扬声器图标,当我点击它的预览,它根本不播放。我不知道我错过了什么。如果有人能帮我的话,请给我一些建议。
发布于 2022-04-29 16:32:17
Aspose.Slides for Python使将视频添加到演示文稿幻灯片变得很容易。下面的代码示例向您展示了如何做到这一点:
import aspose.slides as slides
with slides.Presentation() as presentation:
slide = presentation.slides[0]
# Add a video frame to the slide.
video_frame = slide.shapes.add_video_frame(20, 20, 400, 300, "video.mp4")
# Add a poster image to presentation resources.
with open("poster.png", "rb") as poster_stream:
poster_image = presentation.images.add_image(poster_stream)
# Set the poster for the video.
video_frame.picture_format.picture.image = poster_image
presentation.save("example.pptx", slides.export.SaveFormat.PPTX)这是一个付费产品,但您可以获得评估此库所有功能的临时许可证。我是Aspose的一个支持开发人员。
https://stackoverflow.com/questions/60245554
复制相似问题