# تبدیل PPTX به ویدیو در جاوا

> تبدیل PPTX به ویدیو در جاوا. برای تبدیل پاورپوینت به ویدیو از API کتابخانه جاوا استفاده کنید

Source: https://products.aspose.com/slides/fa/java/conversion/pptx-to-video/
Updated: 2023-05-24



## تبدیل پاورپوینت به ویدیو در جاوا

از این کد جاوا برای تبدیل PPTX به ویدیو استفاده کنید:

### کد جاوا برای تبدیل پاورپوینت به ویدیو

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

## با استفاده از Aspose.Slides پاورپوینت را به ویدیو تبدیل کنید

[**Aspose.Slides for Java**](https://products.aspose.com/slides/fa/java/) یک کتابخانه قدرتمند جاوا است که برای ایجاد، ویرایش و دستکاری ارائه ها و همچنین تبدیل ارائه های پاورپوینت به اسناد و ویدیوهای دیگر استفاده می شود. . در این حالت برای تبدیل پاورپوینت به ویدیو باید از **Aspose.Slides** در کنار **ffmpeg** استفاده کنید.

فرآیند تبدیل PPTX به ویدیو به این صورت است: Aspose.Slides برای تولید مجموعه ای از فریم ها (از اسلایدهای ارائه) و سپس FFMpegCore (ffmpeg) برای ایجاد یک ویدیو بر اساس فریم ها استفاده می شود.

## نحوه تبدیل PPTX به ویدیو

1. با دنبال کردن دستورالعمل‌ها [اینجا](https://docs.aspose.com/slides/java/installation/) **Aspose.Slides را برای جاوا** نصب کنید. **ffmpeg** را از اینجا دانلود کنید (https://ffmpeg.org/download.html)

1. این را به فایل POM خود اضافه کنید:

```
   <وابستگی>
     <groupId>net.bramp.ffmpeg</groupId>
     <artifactId>ffmpeg</artifactId>
     <version>0.7.0</version>
   </dependency>
```

1. پاورپوینت جاوا را کپی، پیست و سپس در کد ویدیو اجرا کنید.

## سایر تبدیل های پشتیبانی شده
