แปลง PPTX เป็นวิดีโอใน Java
Java API ข้ามแพลตฟอร์มอันทรงพลังสำหรับการแปลง PowerPoint เป็นวิดีโอโดยใช้โค้ด Java
แปลง PowerPoint เป็นวิดีโอโดยใช้ Aspose.Slides
Aspose.Slides สำหรับ Java เป็นไลบรารี Java อันทรงพลังที่ใช้สร้าง แก้ไข และจัดการงานนำเสนอ และยังแปลงงานนำเสนอ PowerPoint เป็นเอกสารและวิดีโออื่นๆ . ในกรณีนี้ ในการแปลง PowerPoint เป็นวิดีโอ คุณต้องใช้ Aspose.Slides ควบคู่ไปกับ ffmpeg
นี่เป็นวิธีการทำงานของกระบวนการแปลง PPTX เป็นวิดีโอ: Aspose.Slides ใช้เพื่อสร้างชุดของเฟรม (จากสไลด์การนำเสนอ) จากนั้นใช้ FFMpegCore (ffmpeg) เพื่อสร้างวิดีโอตามเฟรม
วิธีแปลง PPTX เป็นวิดีโอ
แปลง PowerPoint เป็นวิดีโอใน Java
ใช้รหัส Java นี้เพื่อแปลง PPTX เป็นวิดีโอ:
รหัส Java สำหรับการแปลง PowerPoint เป็นวิดีโอ
Presentation presentation = new Presentation();
try {
// Adds a smile shape and then animates it
IAutoShape smile = presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.SmileyFace, 110, 20, 500, 500);
ISequence mainSequence = presentation.getSlides().get_Item(0).getTimeline().getMainSequence();
IEffect effectIn = mainSequence.addEffect(smile, EffectType.Fly, EffectSubtype.TopLeft, EffectTriggerType.AfterPrevious);
IEffect effectOut = mainSequence.addEffect(smile, EffectType.Fly, EffectSubtype.BottomRight, EffectTriggerType.AfterPrevious);
effectIn.getTiming().setDuration(2f);
effectOut.setPresetClassType(EffectPresetClassType.Exit);
final int fps = 33;
ArrayList<String> frames = new ArrayList<String>();
PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation);
try
{
PresentationPlayer player = new PresentationPlayer(animationsGenerator, fps);
try {
player.setFrameTick((sender, arguments) ->
{
try {
String frame = String.format("frame_%04d.png", sender.getFrameIndex());
ImageIO.write(arguments.getFrame(), "PNG", new java.io.File(frame));
frames.add(frame);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
animationsGenerator.run(presentation.getSlides());
} finally {
if (player != null) player.dispose();
}
} finally {
if (animationsGenerator != null) animationsGenerator.dispose();
}
// Configure ffmpeg binaries folder. See this page: https://github.com/rosenbjerg/FFMpegCore#installation
FFmpeg ffmpeg = new FFmpeg("path/to/ffmpeg");
FFprobe ffprobe = new FFprobe("path/to/ffprobe");
FFmpegBuilder builder = new FFmpegBuilder()
.addExtraArgs("-start_number", "1")
.setInput("frame_%04d.png")
.addOutput("output.avi")
.setVideoFrameRate(FFmpeg.FPS_24)
.setFormat("avi")
.done();
FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);
executor.createJob(builder).run();
} catch (IOException e) {
e.printStackTrace();
}
การแปลงอื่น ๆ ที่รองรับ
คุณยังสามารถแปลง PowerPoint เป็นไฟล์ในรูปแบบอื่นๆ