Java에서 PPT를 비디오로 변환

Java 코드를 사용하여 PowerPoint를 비디오로 변환하기 위한 강력한 크로스 플랫폼 Java API

Aspose.Slides를 사용하여 PowerPoint를 비디오로 변환

Aspose.Slides for Java 는 프레젠테이션을 생성, 편집 및 조작하고 PowerPoint 프레젠테이션을 다른 문서 및 비디오로 변환하는 데 사용되는 강력한 Java 라이브러리입니다. . 이 경우 PowerPoint를 비디오로 변환하려면 ffmpeg와 함께 Aspose.Slides를 사용해야 합니다.

이것이 PPT에서 비디오로의 변환 프로세스가 작동하는 방식입니다. Aspose.Slides를 사용하여 (프레젠테이션 슬라이드에서) 일련의 프레임을 생성한 다음 FFMpegCore(ffmpeg)를 사용하여 프레임을 기반으로 비디오를 생성합니다.

PPT를 비디오로 변환하는 방법

  1. 여기 의 지침에 따라 Aspose.Slides for Java를 설치합니다. ffmpeg 여기 에서 다운로드하세요.

  2. POM 파일에 다음을 추가하십시오.

       <의존성>
         <groupId>net.bramp.ffmpeg</groupId>
         <artifactId>ffmpeg</artifactId>
         <버전>0.7.0</버전>
       </의존성>
    

  3. 비디오 코드에 Java PowerPoint를 복사하여 붙여넣은 다음 실행합니다.

Java에서 PowerPoint를 비디오로 변환

이 Java 코드를 사용하여 PPT를 비디오로 변환:

PowerPoint를 비디오로 변환하기 위한 Java 코드


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를 다른 형식의 파일로 변환할 수도 있습니다.