我正在尝试以编程方式将powerpoint演示文稿导出为视频。我试着跟随。1.使用org.apache.poixslf.usermodel.SlideShow打开pptx文件1.根据要求更新幻灯片1.为每张幻灯片创建图像(使用slide.draw())1.通过一个接一个地附加幻灯片图像来创建视频该代码正在生成视频。视频是幻灯片的静态图像的集合。问题是幻灯片中包含的动画在视频中不存在。有没有什么方法可以使用apache.poi或其他选项将动画导出到视频中?
org.apache.poixslf.usermodel.SlideShow
slide.draw()
f45qwnt81#
若要将PowerPoint演示文稿转换为具有形状动画和幻灯片过渡的视频,可以使用Aspose.Slides for Java。此库允许为整个动画生成一组具有特定每秒帧(FPS)的帧。然后,这些帧可以通过FFmpeg等工具用于创建视频。
final int FPS = 30; Presentation presentation = new Presentation("animated.pptx"); try { PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation); try { PresentationPlayer player = new PresentationPlayer(animationsGenerator, FPS); try { player.setFrameTick((sender, args) -> { try { ImageIO.write(args.getFrame(), "PNG", new File("frame_" + sender.getFrameIndex() + ".png")); } catch (IOException e) { throw new RuntimeException(e); } }); animationsGenerator.run(presentation.getSlides()); } finally { if (player != null) player.dispose(); } } finally { if (animationsGenerator != null) animationsGenerator.dispose(); } } finally { if (presentation != null) presentation.dispose(); }
你可以找到更多的细节here。
1条答案
按热度按时间f45qwnt81#
若要将PowerPoint演示文稿转换为具有形状动画和幻灯片过渡的视频,可以使用Aspose.Slides for Java。此库允许为整个动画生成一组具有特定每秒帧(FPS)的帧。然后,这些帧可以通过FFmpeg等工具用于创建视频。
你可以找到更多的细节here。