Search code examples
pythonvideopowerpoint

Can python-pptx module insert video?


according to the documentation, python-pptx can insert videos, however, the documentation does not give very good examples. Anybody have any code snippets to add video1.avi to my pptx?

from pptx import Presentation
pptx1 = Presentation()
slide = pptx1.slides.add_slide(blank_slide_layout)

not sure what inputs I need

slide.placeholders.element.add_placeholder(id_,name,ph_type, orient, sz,idx)

thanks


Solution

  • UPDATE: python-pptx now supports inserting videos (and probably audio in many cases using the same method).


    I'm not sure where in the documentation it says it can insert videos, but if you can cite a particular location I'll fix it.

    We've looked at this feature, but it turns out to be quite complex as different video formats require a substantial amount of undocumented customization to the metadata inserted into the XML surrounding the embedded video object. Also as I recall one needs a way to get a still image (first frame maybe) from the video to insert in it's place while it's not running, and libraries for this sort of thing are not readily available in Python last time we looked.

    Anyway, the short answer is no, it's not supported yet. And it's not likely to come soon unless there's a motivated contributor or sponsor. Sorry I didn't have happier news for you :(