scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.46k stars 528 forks source link

Start Time for add_movie #811

Open MartinPacker opened 2 years ago

MartinPacker commented 2 years ago

I'm currently using add_movie() to add videos and audio. HTML seems to allow both the <video> and the <audio> element to specify a start time. It's part of the URL.

Is it feasible to embed eg a video in a page and then fix it up - with custom XML perhaps - to play from a specified start time?

I'm perfectly prepared to inject the necessary XML in my own code (md2pptx) - if it turns out to be feasible.

(I'm asking this here - rather than on Stack Overflow - as an affirmative answer might lead to request to enhance add_movie() with a Start Time optional parameter.)

scanny commented 2 years ago

If you can do it in PowerPoint (the app) then you can do it in the XML. Generally I've found the quickest way to get in the neighborhood of where to make the change is to do a before and after with PowerPoint and inspect the XML. From there you can study the schema in that neighborhood and consult the PowerPoint API which together would generally give you a pretty full view.

MartinPacker commented 2 years ago

Thanks @scanny. That was my guess.

I'll try it and report back.

MartinPacker commented 2 years ago

I'm drawing a blank on this: There are no workable solutions on the web as to how to start the movie from a particular point.

scanny commented 2 years ago

This doesn't work? https://www.officeoneonline.com/ppttips/video_start_stop_time.html

MartinPacker commented 2 years ago

It doesn't seem to on Mac - which is the only place I could try to set it up. (And yes I had tried to follow these instructions before I gave up.)

scanny commented 2 years ago

Ah, so that could be an authoring-time feature disparity on the Mac, there are quite a few of those sprinkled around in some of the more advanced features. If you are able to get a before and after produced on Windows (maybe even just the after version) then the feature may well work at run-time, I expect it would actually. So harder to do the analysis, that happens sometimes. Luckily for me my wife runs on Windows so I can always check over there in situations like this.

Maybe someone else who wants this feature can help with a specimen. The other approach would be to study the XML schema looking for possible attributes on video or possibly finding a "starts-in-the-middle" example online somewhere and inspecting that XML for clues.