Java’da PPT’yi videoya dönüştürün

Java kodunu kullanarak PowerPoint’i videoya dönüştürmek için güçlü platformlar arası Java API’si

Aspose.Slides kullanarak PowerPoint'i videoya dönüştürün

Aspose.Slides for Java , sunumlar oluşturmak, düzenlemek ve değiştirmek ve ayrıca PowerPoint sunumlarını diğer belgelere ve videolara dönüştürmek için kullanılan güçlü bir Java kitaplığıdır. . Bu durumda, PowerPoint’i videoya dönüştürmek için ffmpeg ile birlikte Aspose.Slides kullanmanız gerekir.

PPT’den videoya dönüştürme işlemi şu şekilde çalışır: Aspose.Slides, bir dizi kare (sunum slaytlarından) oluşturmak için kullanılır ve ardından FFMpegCore (ffmpeg), karelere dayalı bir video oluşturmak için kullanılır.

PPT'i videoya dönüştürme

  1. Aspose.Slides for Java‘yı buradaki talimatları izleyerek kurun. ffmpeg‘i [buradan] indirin( https://ffmpeg.org/download.html )

  2. Bunu POM dosyanıza ekleyin:

       <bağımlılık>
         <groupId>net.bramp.ffmpeg</groupId>
         <artifactId>ffmpeg</artifactId>
         <version>0.7.0</version>
       </bağımlılık>
    

  3. Java PowerPoint to video kodunu kopyalayın, yapıştırın ve çalıştırın.

Java'da PowerPoint'i videoya dönüştürün

PPT’yi videoya dönüştürmek için bu Java kodunu kullanın:

PowerPoint'i videoya dönüştürmek için Java kodu


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();
}

Desteklenen Diğer Dönüşümler

PowerPoint'i başka biçimlerdeki dosyalara da dönüştürebilirsiniz.