当前位置: 首页 > news >正文

上海网站制作怎么样网站会员推广邀请系统

上海网站制作怎么样,网站会员推广邀请系统,ai做网站步骤,明年做那些网站致富无论是在教室、会议室还是虚拟会议中,PowerPoint 演示文稿都已成为一种无处不在的工具,用于提供具有影响力的可视化内容。PowerPoint 提供了一系列增强演示的功能,在其中加入视频的功能可以大大提升整体体验。视频可以传达复杂的概念、演示产…

无论是在教室、会议室还是虚拟会议中,PowerPoint 演示文稿都已成为一种无处不在的工具,用于提供具有影响力的可视化内容。PowerPoint 提供了一系列增强演示的功能,在其中加入视频的功能可以大大提升整体体验。视频可以传达复杂的概念、演示产品功能或添加吸引观众的元素。然而,在 PowerPoint 演示文稿中手动管理视频既费时又繁琐。这时,Python 这种通用编程语言就能发挥作用,提供一种简化的方法来插入、替换或检索 PowerPoint 演示文稿中的视频。本文将介绍如何利用 Python 在 PowerPoint 中管理视频,包括插入视频到PPT、替换PPT中的视频以及提取PPT中的视频。

文章目录

    • 用Python添加视频到PPT中指定幻灯片的指定位置
    • 用Python替换PPT中指定视频为新的视频
    • 用Python提取PPT幻灯片中的视频
      • 总结

本文所介绍的方法需要用到Spire.Presentation for Python,可从官网下载或通过PyPI安装:pip install Spire.Presentation

用Python添加视频到PPT中指定幻灯片的指定位置

插入到PPT中的视频可以直接在PPT中播放,不需要额外的插件。且视频嵌入到PPT中,无需额外储存。以下是详细操作步骤:

  • 创建 Presentation 类的实例
  • 使用 Presentation.LoadFromFile() 方法加载 PowerPoint 文档。
  • 通过 Presentation.Slides[] 方法根据索引获取特定幻灯片。
  • 创建 RectangleF 类的实例。
  • 使用 ISlide.Shapes.AppendVideoMedia(String, RectangleF) 方法为幻灯片添加视频。
  • 通过 IVideo.PictureFill.Picture.Url 属性为视频设置缩略图。
  • 使用 Presentation.SaveToFile() 方法保存结果文档。

代码示例:

from spire.presentation.common import *
import math
from spire.presentation import *# 创建Presentation对象
presentation = Presentation()# 载入演示文稿
presentation.LoadFromFile("Sample.pptx")# 添加视频标题
rec_title = RectangleF.FromLTRB(50, 280, 160+50, 50+280)
shape_title = presentation.Slides[1].Shapes.AppendShape(ShapeType.Rectangle, rec_title)
shape_title.ShapeStyle.LineColor.Color = Color.get_Transparent()shape_title.Fill.FillType = FillFormatType.none
para_title = TextParagraph()
para_title.Text = "视频:"
para_title.Alignment = TextAlignmentType.Center
para_title.TextRanges[0].LatinFont = TextFont("HarmonyOS Sans SC")
para_title.TextRanges[0].FontHeight = 32
para_title.TextRanges[0].IsBold = TriState.TTrue
para_title.TextRanges[0].Fill.FillType = FillFormatType.Solid
para_title.TextRanges[0].Fill.SolidColor.Color = Color.FromArgb(255, 68, 68, 68)
shape_title.TextFrame.Paragraphs.Append(para_title)# 添加视频
left = math.trunc(presentation.SlideSize.Size.Width / float(2)) - 125
videoRect = RectangleF.FromLTRB(left, 300, 150+left, 150+240)
video = presentation.Slides[1].Shapes.AppendVideoMedia("Cat1.mp4", videoRect)
video.PictureFill.Picture.Url = "https://i.postimg.cc/zfspqJKC/Cat1.png"# Save the document
presentation.SaveToFile("output/添加视频.pptx", FileFormat.Pptx2010)
presentation.Dispose()

添加结果:
Python添加视频到PowerPoint演示文稿

用Python替换PPT中指定视频为新的视频

操作步骤如下:

  • 创建 Presentation 类的实例
  • 使用 Presentation.LoadFromFile() 方法加载 PowerPoint 文档。
  • 通过 Presentation.Videos 属性获取文档中嵌入的视频。
  • 通过 Presentation.Slides[] 属性获取幻灯片。
  • 遍历幻灯片中的形状,并判断形状是否为 IVideo 实例。如果是,则进行替换操作。
  • 使用 VideoCollection.AppendByStream() 方法将视频数据嵌入到文档。
  • 通过 IVideo.EmbeddedVideoData 属性将视频数据设置为改视频形状的视频数据。
  • 通过 IVideo.PictureFill.Picture.Url 设置新的预览图。
  • 使用 Presentation.SaveToFile() 保存演示文稿。

代码示例:

from spire.presentation.common import *
from spire.presentation import *# 创建Presentation对象
presentation = Presentation()# 载入演示文稿
presentation.LoadFromFile("output/添加视频.pptx")# 获取演示文稿中嵌入的视频
videos = presentation.Videos# 获取视频所在幻灯片
sld = presentation.Slides[1]# 遍历幻灯片中的形状
for sp in sld.Shapes:# 判断形状是否为IVideo实例if isinstance(sp, IVideo):video = sp if isinstance(sp, IVideo) else None# 载入视频stream = Stream("Cat2.mp4")# 将视频嵌入到演示文稿videoData = videos.AppendByStream(stream)# 将视频设置为形状的视频video.EmbeddedVideoData = videoData# 设置新预览图video.PictureFill.Picture.Url = "https://i.postimg.cc/kX1fGrbp/Cat2.png"# 保存文档
presentation.SaveToFile("output/替换视频.pptx", FileFormat.Pptx2016)
presentation.Dispose()

替换结果:
Python替换PowerPoint演示文稿视频

用Python提取PPT幻灯片中的视频

通过此API可以轻松提取演示文稿中的所有视频,并保存到指定文件夹。以下是操作步骤:

  • 创建 Presentation 类的实例
  • 使用 Presentation.LoadFromFile() 方法加载 PowerPoint 文档。
  • 遍历演示文稿中的幻灯片,再遍历幻灯片中的形状,并判断形状是否为视频。
  • 如果形状是视频,则使用 IVideo.EmbeddedVideoData.SaveToFile() 方法保存视频到指定位置。

代码示例:

from spire.presentation.common import *
from spire.presentation import *# 创建Presentation对象
presentation = Presentation()# 载入演示文稿
presentation.LoadFromFile("output/替换视频.pptx")i = 0
result = "output/Videos/" + "ExtractVideo_"+str(i)+".mp4"# 遍历演示文稿中的幻灯片
for slide in presentation.Slides:# 遍历幻灯片中的形状for shape in slide.Shapes:# 判断形状是否为视频if isinstance(shape, IVideo):# 保存视频shape.EmbeddedVideoData.SaveToFile(result)i += 1
presentation.Dispose()

提取效果:
Python提取PowerPoint演示文稿视频

总结

本文介绍了如何使用Python代码处理PowerPoint演示文稿中的视频,包括添加视频、替换视频和提取视频,帮助开发者以更简单的方式对演示文稿中的视频进行操作。

Spire.Presentation for Python还支持许多其他PowerPoint文档操作,请前往Spire.Presentation for Python教程查看。

申请免费License

http://www.yayakq.cn/news/148645/

相关文章:

  • 新邵县住房和城乡建设局网站网站建设全程揭秘 课件下载
  • 昆明公司网站开发互联网营销主要学什么
  • 网站导航二级菜单怎么做出来的网站建设项目付款方式
  • 文化传播集团网站建设wordpress作者页制作
  • 怎么用linux做网站服务器网站流量通道
  • 建设厅网站上报名常州企业家坠楼公司发讣告后删除
  • 装饰公司网站建设方案求个企业邮箱号
  • 中国数据统计网站git做网站根目录
  • 如何实施网站推广做英语翻译兼职的网站
  • 大什么的网站建设公司sem是什么分析方法
  • 网站设计命名规范项链seo关键词
  • 坡头网站建设公司周村区住房和城乡建设厅网站
  • 网站建设接口开发如皋网站设计
  • 乐清网站推广制作郑州个人网站建设公司排行榜
  • 广州 网站定制江苏住房和城乡建设厅官网
  • 谷歌外贸建站多少钱百度账号申请注册
  • 做网站现在要多少钱全景网站如何建设
  • 杭州营销网站制作设计单网站建设
  • 视频网站开发教程建设网站项目概述
  • 装潢设计图片衡阳网站推广优化公司
  • 58招聘网站官网wordpress淡出
  • 定制衣服的厂家福州搜索优化行业
  • 怎样做好网站建设毕业设计代做网站推荐
  • 江苏宜安建设有限公司网站网站不续费
  • 梅河口市住房和城乡建设局网站网站后台建设教程下载
  • 室内设计网站平台网站做关键词首页
  • 视觉传达设计网站网站建站要求
  • 做网站 业务流程图徐州建站模板公司
  • 工具类网站开发wordpress没有页脚
  • 怎么网站建设公司2020最新推广方式