'Adding video in ppt using python cannot be played

I have to insert a video in ppt using python-pptx library. And also i have added the below code to insert it:

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)

This code successfully creates video shape. It show a big speaker icon when i click it for preview, it doesn't play at all . I dont know what i missed here. If anyone could help me please give some suggestion for this.



Solution 1:[1]

Aspose.Slides for Python makes it easy to add video to a presentation slide. The following code example shows you how to do this:

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)

This a paid product, but you can get a temporary license to evaluate all features of this library. I work as a Support Developer at Aspose.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andrey Potapov