目录

用于在 PowerPoint 演示文稿中嵌入视频的 C++ API

使用 C++ 在 PowerPoint 演示文稿中嵌入视频

在 PowerPoint 演示文稿中嵌入来自 Web 源的视频

使用 C++ 从 PowerPoint 演示文稿中提取视频

Microsoft PowerPoint 使您能够将视频帧添加到 PowerPoint 演示文稿中。视频可用于提高演示的质量,并有助于更好地向观众传达信息。在某些情况下,您可能希望以编程方式向 PowerPoint 演示文稿添加视频。为此,本文将教您 如何使用 C++ 在 PowerPoint 演示文稿中嵌入视频。

用于在 PowerPoint 演示文稿中嵌入视频的 C++ API

我们将使用Aspose.Slides for C++ API 在 PowerPoint 演示文稿中嵌入视频。它是一个强大且功能丰富的 API,支持创建、阅读和修改 PowerPoint 文件,而无需安装 Mircosoft PowerPoint。

使用 C++ 在 PowerPoint 演示文稿中嵌入视频

以下是在 PowerPoint 演示文稿中嵌入视频的步骤。

  1. 首先,创建一个Presentation 类的实例 来表示一个新的 PowerPoint 文件。
  2. 检索要嵌入视频的幻灯片。
  3. 使用Presentation->get_Videos()->AddVideo(System::SharedPtr<System::IO::Stream> 流)方法将视频添加到演示文稿中。
  4. 使用ISlide->get_Shapes()->AddVideoFrame(float x, float y, float width, float height, System::SharedPtr< IVideo > video)方法添加视频帧。
  5. 使用IVideoFrame->set_EmbeddedVideo(System::SharedPtr<IVideo> value)方法将视频嵌入到视频帧中。
  6. 设置视频的播放模式和音量。
  7. 最后,使用 Presentation->Save(System::String fname, Export::SaveFormat format) 方法保存演示文稿。

以下示例代码展示了如何使用 C++ 在 PowerPoint 演示文稿中嵌入视频。

// File paths
const String videoFilePath = u"SourceDirectory\\Video\\Wildlife.mp4";
const String outputFilePath = u"OutputDirectory\\EmbedVideo_out.pptx";// Create an instance of the Presentation class
SharedPtr<Presentation> presentation = MakeObject<Presentation>();// Access the first slide
SharedPtr<ISlide> slide = presentation->get_Slides()->idx_get(0);// Load the video file to stream
System::SharedPtr<System::IO::Stream> stream = System::MakeObject<System::IO::FileStream>(videoFilePath, System::IO::FileMode::Open, System::IO::FileAccess::Read);// Add the video to the presentation
System::SharedPtr<IVideo> vid = presentation->get_Videos()->AddVideo(stream);// Add video frame
System::SharedPtr<IVideoFrame> videoFrame = slide->get_Shapes()->AddVideoFrame(50, 150, 300, 150, vid);// Embed video inside the video frame
videoFrame->set_EmbeddedVideo(vid);// Set the play mode and volume of the video
videoFrame->set_PlayMode(VideoPlayModePreset::Auto);
videoFrame->set_Volume(AudioVolumeMode::Loud);// Save the presentation
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);

在 PowerPoint 演示文稿中嵌入来自 Web 源的视频

以下是在 PowerPoint 演示文稿中嵌入来自 Web 源的视频的步骤。

  1. 首先,创建一个Presentation 类的实例 来表示一个新的 PowerPoint 文件。
  2. 检索要嵌入视频的幻灯片。
  3. 使用ISlide->get_Shapes()->AddVideoFrame(float x, float y, float width, float height, System::String fname)方法添加视频帧。
  4. 设置视频的播放模式。
  5. 最后,使用 Presentation->Save(System::String fname, Export::SaveFormat format) 方法保存演示文稿。

以下示例代码展示了如何使用 C++ 在 PowerPoint 演示文稿中嵌入来自 Web 源的视频。

// File path
const String outputFilePath = u"OutputDirectory\\EmbedVideoFromWeb_out.pptx";// Create an instance of the Presentation class
SharedPtr<Presentation> presentation = MakeObject<Presentation>();// Access the first slide
SharedPtr<ISlide> slide = presentation->get_Slides()->idx_get(0);// Add the video frame from web source
System::SharedPtr<IVideoFrame> videoFrame = slide->get_Shapes()->AddVideoFrame(10, 10, 427, 240, u"https://www.youtube.com/embed/sZJorZmHiIk");// Set the play mode and volume of the video
videoFrame->set_PlayMode(VideoPlayModePreset::Auto);// Save the presentation
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);

使用 C++ 从 PowerPoint 演示文稿中提取视频

以下是使用 C++ 从 PowerPoint 演示文稿中提取视频的步骤。

  1. 首先,使用Presentation 类加载 PowerPoint 文件 。
  2. 循环播放演示文稿的幻灯片。
  3. 循环浏览每张幻灯片中的形状。
  4. 对于每个形状,检查形状是否为VideoFrame。如果是视频帧,则提取嵌入的视频并保存。

以下示例代码显示了如何使用 C++ 从 PowerPoint 演示文稿中提取视频。

// File paths
const String sourceFilePath = u"OutputDirectory\\EmbedVideo_out.pptx";
const String outputFilePath = u"OutputDirectory\\ExtractVideoFromSlide_out.";// Load the presentation file
System::SharedPtr<Presentation> presentation = System::MakeObject<Presentation>(sourceFilePath);
{
// Loop through the slides
auto slide_enumerator = (presentation->get_Slides())->GetEnumerator();
decltype(slide_enumerator->get_Current()) slide;
while (slide_enumerator->MoveNext() && (slide = slide_enumerator->get_Current(), true))
{
// Loop through the shapes
auto shape_enumerator = (presentation->get_Slides()->idx_get(0)->get_Shapes())->GetEnumerator();
decltype(shape_enumerator->get_Current()) shape;
while (shape_enumerator->MoveNext() && (shape = shape_enumerator->get_Current(), true))
{
// Check if the shape is a video frame
if (System::ObjectExt::Is<VideoFrame>(shape))
{
// Extract the video file
System::SharedPtr<VideoFrame> vf = System::DynamicCast_noexcept<Aspose::Slides::VideoFrame>(shape);
System::String type = vf->get_EmbeddedVideo()->get_ContentType();
int32_t ss = type.LastIndexOf(L'/');
type = type.Remove(0, type.LastIndexOf(L'/') + 1);
System::ArrayPtr<uint8_t> buffer = vf->get_EmbeddedVideo()->get_BinaryData();
{
System::SharedPtr<System::IO::FileStream> stream = System::MakeObject<System::IO::FileStream>(outputFilePath + type, System::IO::FileMode::Create, System::IO::FileAccess::Write, System::IO::FileShare::Read);// Clearing resources under 'using' statement
//System::Details::DisposeGuard __dispose_guard_0{ stream, ASPOSE_CURRENT_FUNCTION };
// ------------------------------------------
stream->Write(buffer, 0, buffer->get_Length());
}
}
}
}
}

Aspose.Slides使用教程:使用 C++ 在 PowerPoint 演示文稿中嵌入视频相关推荐

  1. [教程]如何在PowerPoint演示文稿中嵌入交互式图表

    在PowerPoint演示文稿中嵌入图表并不稀奇,但也许最被忽视的是直接在演示稿中嵌入网络应用. 但您知道这是可以做到的吗? 如前所述,可以说这是一个鲜为人知的功能.我们在LightningChart ...

  2. Aspose.Slides使用教程:使用 C# 在 PowerPoint 演示文稿中添加页眉和页脚

    目录 在 PowerPoint 中管理页眉和页脚的 .NET API 使用 C# 管理讲义和备注幻灯片中的页眉和页脚 更改备注幻灯片的页眉和页脚设置 PowerPoint 演示文稿中的页眉和页脚用于显 ...

  3. Aspose.Slides使用教程:使用 C++ 在 PowerPoint 演示文稿中添加幻灯片切换

    目录 用于在 PowerPoint 演示文稿中添加过渡的 C++ API 使用 C++ 添加幻灯片过渡 使用 C++ 添加高级幻灯片过渡 在 PowerPoint 演示文稿中设置变形过渡类型 在 Mi ...

  4. PPT处理控件Aspose.Slides功能演示:使用 C# 在 PowerPoint 演示文稿中创建 SmartArt

    演示文稿中的 SmartArt 用于以视觉形式提供信息.有时,选择使简单的文本更具吸引力.而在其他情况下,它用于演示流程图.流程.不同实体之间的关系等.下面将介绍如何使用 C# 以编程方式在 Powe ...

  5. 文档处理教程:使用C#在PowerPoint演示文稿中创建图表

    图表用于汇总和直观表示PowerPoint演示文稿中的数据.因此,PowerPoint提供了多种图表类型以可视化数据.其中,最常用的图表类型包括饼图,折线图,条形图,直方图,股票图等.在本文中,将学习 ...

  6. 如何在PowerPoint演示文稿中使用iTunes音乐

    One of PowerPoint's charms is its ability to play music during the presentation. Adding music to you ...

  7. ppt中的流程图怎么整体移动_小金在PowerPoint演示文稿中绘制了一个包含多个图形的流程图,他希望该流程图中的所有图形可以作为一个整体移动,最优的操作方法是______...

    小金在PowerPoint演示文稿中绘制了一个包含多个图形的流程图,他希望该流程图中的所有图形可以作为一个整体移动,最优的操作方法是______ 答:选择流程图中的所有图形,通过\"绘图工具 ...

  8. 将其他程序中的大纲文本插入到 PowerPoint 演示文稿中

    如果要根据现有报告或其他分级显示的文档(在 Microsoft Office Word 2007 中或其他任何支持使用标题样式的程序中创建)制作演示文稿,则可以通过将文档插入到 Microsoft O ...

  9. PowerPoint演示文稿中设置自定义动画

    动态的东西,总是给人活灵活现的感觉.在制作演示文稿时,除了会设置幻灯片的切换方式外,还通常会为幻灯片中的某些内容(如图片.文字等)设置动画效果,使幻灯片欣赏起来不至于太呆板. 1.制作进入动画效果 选 ...

最新文章

  1. [CF1042F]Leaf Sets
  2. shell   %% , ##,#,% 用法
  3. java做猜价格游戏,用java做的猜数游戏!
  4. VC++获取屏幕大小第二篇 物理大小GetDeviceCaps 上
  5. SQL笔记-检索出ID为Int或Long中不连续的第一个点
  6. RDS For SQL Server链接服务器
  7. C++获取文本文件字节数的一个小方法
  8. 魅族手机便签里的备忘录内容如何导出到华为手机上?
  9. FI-MM-CO T-CODE (中英文)
  10. iphone屏幕镜像如何全屏_苹果手机投到电视上能全屏嘛 具体怎样投屏呢
  11. win10安装visio2010出错_win10安装office2010时显示错误1907如何解决
  12. 凸优化理论基础3——凸集和凸锥重要例子
  13. UTF8与GBK字符编码之间的相互转换
  14. org.quartz.JobPersistenceException: Couldn‘t store job:
  15. 在线教育网站的一些瞎折腾……
  16. Python实战技巧(9)Python发送邮件
  17. CPA二十一--套期保值业务(转载)
  18. 中了敲诈者病毒,文件恢复有可能吗?你长着一张被勒索木马敲诈的脸?
  19. 心理学专业转用户体验_用户体验设计心理学
  20. 2022华为开发者大赛北区决赛在1024程序员节北京峰会成功举行

热门文章

  1. Hugging Face
  2. Makefile万能模板
  3. java中的onresume_android onCreate onResume中获取 View 宽高为0分析
  4. ado .net oracle varray,ADO.NET调用ORACLE 11g存储过程问题
  5. 2021牛客寒假算法基础集训营5 比武招亲(上)(组合数)
  6. Layui表单元素的赋值
  7. 415dakuanghuan
  8. Java培训实战教程之叩丁狼JavaNIO分享
  9. WLAN无法自动打开问题分析
  10. 【闪耀DTCC】黄金合作伙伴浪擎信息科技助力DTCC2016!