Convertir PPT a video en Java
Potente API Java multiplataforma para convertir PowerPoint a video usando código Java
Convierta PowerPoint a video usando Aspose.Slides
Aspose.Slides for Java es una poderosa biblioteca de Java utilizada para crear, editar y manipular presentaciones y también convertir presentaciones de PowerPoint en otros documentos y videos. . En este caso, para convertir PowerPoint a video, debe usar Aspose.Slides junto con ffmpeg.
Así es como funciona el proceso de conversión de PPT a video: Aspose.Slides se usa para generar un conjunto de cuadros (a partir de las diapositivas de la presentación) y luego se usa FFMpegCore (ffmpeg) para crear un video basado en los cuadros.
Cómo convertir PPT a video
Instale Aspose.Slides para Java siguiendo las instrucciones aquí . Descarga ffmpeg aquí.
Agregue esto a su archivo POM:
<dependencia> <groupId>net.bramp.ffmpeg</groupId> <artifactId>ffmpeg</artifactId> <versión>0.7.0</versión> </dependencia>
Copie, pegue y luego ejecute el código de Java PowerPoint a video.
Convertir PowerPoint a video en Java
Use este código Java para convertir PPT a video:
Código Java para convertir PowerPoint a video
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();
}
Otras conversiones admitidas
También puede convertir PowerPoint a archivos en otros formatos