feature: insert video clip
Hi Neal, changing the title of this one as it's not a lack of documentation but rather that there is no .add_video() feature yet. Based on a first analysis, this one looks like it will be a big effort, so it's not likely to come anytime soon unless a contributor or sponsor wants it bad enough to make it happen :)
Steve, OK, thanks for correcting that. I would love to contribute but do not really have the resources now. Thanks for such a punctual response.
Hello @scanny could you give me a quick run-through of what this feature might require in terms of work? I may be able to build it.
Hi Mark, as far as I was able to tell this one was going to be a substantial effort. In particular it looked like there was a lot of undocumented differences between specific video formats. The place to start would be by diff-ing packages (.pptx files) before and after inserting a video.
Happy to provide more input once you get into to it.
+1 for this feature request
Hey @scanny. I tried the diff you mentioned and didn't seem to find anything extremely odd: diff of slide1.xml no media vs. with video: https://www.diffchecker.com/KfwFolVD diff of slide1.xml no media vs. with picture: https://www.diffchecker.com/Pet9QcdJ
I also took a look at the 29500-1 (2016, 4th edition. Section: 15.2.7) spec re this feature and it didn't specify any differences re format. Moreover there was a strong indication that the various formats can be treated similarly as they list all the various formats and present one example on how to create a part relationship for the video. There was however one note re inter-operability: "A producer that wants interoperability should use the following standard format: video/mpeg ISO/IEC 13818"
Am I missing something obvious as to why this feature may be more involved than what we can see at a first glance?
@riteshreddyr I'm actually just finishing up this feature now, believe it or not :) A generous sponsor stepped up and has sponsored me to add it; I'm about 70% through the TDD and merge but haven't pushed it as it's not stable yet.
You're right that it wasn't as involved as I had thought based on my initial inspection. It's still a solid week's work, but seems to be fairly consistent between various formats. There was some variation in the way video's were done in the XML for pre-Office 2010 versions but it still seems straightforward enough.
There's a spiked version of this (pre-merge version, no tests but works and proves concept) on the feature/video branch if you want to give it a go. The docs page in the tip commit on that branch should give an idea how to work it. Basically it's:
movie_shape = shapes.add_video(
filename, left, top, width, height, poster_frame_file, content_type
)
https://github.com/scanny/python-pptx/commit/bfb26439f4587d6ce62990f926101bf8d6852ffd#diff-1d88876332cab20ad0a0016e89958003R501
What video formats are you thinking about using? I've only had MP4 in my test set and running on Mac PowerPoint 2011, so if you have any different examples I could use your help to make sure it's working with other types.
Would this work with adding sound files? Particularly, I'm trying to add narration to each slide from a file.
Not without adjustments, but the underlying XML is largely the same for audio and video.