2024年9月
Aspose.Slides for .NET PPT转视频
Aspose.Slides for .NET 22.11 新增将演示文稿转换为视频(将 PowerPoint 演示文稿转换为具有动画和过渡效果的视频)
Aspose.Slides 现在可以播放演示文稿,并以特定的每秒帧数 (FPS) 为整个动画生成一组帧。然后可以使用这些帧通过 FFmpeg 等工具创建视频。
此 C# 代码演示了将演示文稿导出为视频的操作,其中帧设置为 30FPS:
const int FPS = 30;
using (Presentation presentation = new Presentation("animated.pptx"))
{
using (var animationsGenerator = new PresentationAnimationsGenerator(presentation))
using (var player = new PresentationPlayer(animationsGenerator, FPS))
{
player.FrameTick += (sender, args) =>
{
args.GetFrame().Save($"frame_{sender.FrameIndex}.png");
};
animationsGenerator.Run(presentation.Slides);
}
}PresentationAnimationsGenerator类是一个按顺序生成单个动画效果的源,然后使用PresentationPlayer类播放这些效果。每个帧都会生成一个FrameTick事件,以便您可以将当前帧保存到磁盘或将帧写入视频流。
教程:https://blog.aspose.com/slides/convert-ppt-to-video-csharp/