PowerPoint bemutatók konvertálása videóvá Androidon

Bevezetés

PowerPoint előadás videóvá konvertálásával a következő előnyöket kapja

  • A hozzáférhetőség növekedése: Minden eszköz (függetlenül a platformtól) alapértelmezetten videolejátszóval rendelkezik a bemutató‑megnyitó alkalmazásokhoz képest, így a felhasználók könnyebben nyitják meg vagy játszák le a videókat.
  • Nagyobb elérés: Videók segítségével széles közönséget érhet el, és olyan információval célozhatja meg őket, ami egy bemutatóban esetleg unalmasnak tűnne. A legtöbb felmérés és statisztika azt mutatja, hogy az emberek a videókat többet nézik és fogyasztják, mint más tartalmakat, és általában ezt a formát részesítik előnyben.

PowerPoint videóvá konvertálása az Aspose.Slides-ben

Az Aspose.Slides támogatja a bemutató videóvá konvertálását.

  • Használja a Aspose.Slides-t, hogy a bemutató diákból kereteket (frame-eket) állítson elő, amelyek egy adott FPS‑nek (képkocka per másodperc) felelnek meg
  • Használjon egy harmadik fél eszközt, például a ffmpeg-et (for java) a keretek alapján videó létrehozásához.

PowerPoint videóvá konvertálása

  1. Adja hozzá ezt a POM fájlhoz:
   <dependency>
     <groupId>net.bramp.ffmpeg</groupId>
     <artifactId>ffmpeg</artifactId>
     <version>0.7.0</version>
   </dependency>
  1. Töltse le az ffmpeg-et itt.

  2. Futtassa a PowerPoint videó Java kódot.

Ez a Java kód bemutatja, hogyan konvertáljon egy prezentációt (amely egy ábrát és két animációs effektust tartalmaz) videóvá:

Presentation presentation = new Presentation();
try {
    // Hozzáad egy mosoly alakzatot, majd animálja
    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());
                    arguments.getFrame().save(frame, ImageFormat.Png);
                    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();
    }

    // Állítsa be az ffmpeg binárisok mappáját. Lásd ezt az oldalt: 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();
}

Videóeffektek

Animációkat alkalmazhat a diák objektumaira, és áttűnéseket használhat a diák között.

Az animációk és áttűnések élvezetesebbé és érdekesebbé teszik a diavetítéseket – és ugyanígy működnek a videókkal is. Adjunk egy új diát és áttűnést a korábbi prezentáció kódjához:

// Hozzáad egy mosoly alakzatot és animálja

// ...

// Hozzáad egy új diát és animált átmenetet

ISlide newSlide = presentation.getSlides().addEmptySlide(presentation.getSlides().get_Item(0).getLayoutSlide());

newSlide.getBackground().setType(BackgroundType.OwnBackground);

newSlide.getBackground().getFillFormat().setFillType(FillType.Solid);

newSlide.getBackground().getFillFormat().getSolidFillColor().setColor(Color.MAGENTA);

newSlide.getSlideShowTransition().setType(TransitionType.Push);

Az Aspose.Slides szöveganimációt is támogat. Így animáljuk az objektumok bekezdéseit, amelyek egyesével fognak megjelenni (az késleltetés egy másodpercre van beállítva):

Presentation presentation = new Presentation();
try {
    // Szöveget és animációkat ad hozzá
    IAutoShape autoShape = presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 210, 120, 300, 300);
    Paragraph para1 = new Paragraph();
    para1.getPortions().add(new Portion("Aspose Slides for Java"));
    Paragraph para2 = new Paragraph();
    para2.getPortions().add(new Portion("convert PowerPoint Presentation with text to video"));

    Paragraph para3 = new Paragraph();
    para3.getPortions().add(new Portion("paragraph by paragraph"));
    IParagraphCollection paragraphCollection = autoShape.getTextFrame().getParagraphs();
    paragraphCollection.add(para1);
    paragraphCollection.add(para2);
    paragraphCollection.add(para3);
    paragraphCollection.add(new Paragraph());

    ISequence mainSequence = presentation.getSlides().get_Item(0).getTimeline().getMainSequence();
    IEffect effect1 = mainSequence.addEffect(para1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
    IEffect effect2 = mainSequence.addEffect(para2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
    IEffect effect3 = mainSequence.addEffect(para3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
    IEffect effect4 = mainSequence.addEffect(para3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);

    effect1.getTiming().setTriggerDelayTime(1f);
    effect2.getTiming().setTriggerDelayTime(1f);
    effect3.getTiming().setTriggerDelayTime(1f);
    effect4.getTiming().setTriggerDelayTime(1f);

    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());
                    arguments.getFrame().save(frame, ImageFormat.Png);
                    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();
    }

    // Állítsa be az ffmpeg binárisok mappáját. Lásd ezt az oldalt: 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();
}

Videókonverziós osztályok

A PowerPoint videóvá konvertálásához szükséges feladatok elvégzéséhez az Aspose.Slides biztosítja a PresentationAnimationsGenerator és a PresentationPlayer osztályokat.

[PresentationAnimationsGenerator] lehetővé teszi a videó képkockaméretének beállítását (amelyet később létrehoznak) a konstruktorán keresztül. Ha átad egy prezentáció példányt, a Presentation.SlideSize lesz használva, és olyan animációkat generál, amelyeket a [PresentationPlayer] használ.

Amikor az animációk generálódnak, egy NewAnimation esemény jön létre minden egyes következő animációhoz, amelynek van egy [IPresentationAnimationPlayer] paramétere. Az utóbbi egy osztály, amely egy külön animáció lejátszóját képviseli.

Az [IPresentationAnimationPlayer] használatához a [Duration] (az animáció teljes időtartama) tulajdonságot és a [SetTimePosition] metódust használjuk. Minden animáció pozíciója a 0 és a duration tartományon belül van beállítva, majd a GetFrame metódus egy BufferedImage-et ad vissza, amely az adott pillanatban az animáció állapotát mutatja:

Presentation presentation = new Presentation();
try {
    // Hozzáad egy mosoly alakzatot és animálja
    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);

    PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation);
    try {
        animationsGenerator.setNewAnimation(animationPlayer ->
        {
            System.out.println(String.format("Animation total duration: %f", animationPlayer.getDuration()));
            animationPlayer.setTimePosition(0); // kezdeti animáció állapota
            try {
                // kezdeti animáció állapota bitmap
                animationPlayer.getFrame().save("firstFrame.png", ImageFormat.Png);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            animationPlayer.setTimePosition(animationPlayer.getDuration()); // animáció végső állapota
            try {
                // animáció utolsó képkockája
                animationPlayer.getFrame().save("lastFrame.png", ImageFormat.Png);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        });
    } finally {
        if (animationsGenerator != null) animationsGenerator.dispose();
    }
} finally {
    if (presentation != null) presentation.dispose();
}

Ahhoz, hogy a prezentáció összes animációja egyszerre játsszon le, a [PresentationPlayer] osztályt használjuk. Ez az osztály a konstruktorában kap egy [PresentationAnimationsGenerator] példányt és az FPS-t a hatásokhoz, majd a FrameTick eseményt hívja meg az összes animációhoz, hogy lejátszásra kerüljenek:

Presentation presentation = new Presentation("animated.pptx");
try {
    PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation);
    try {
        PresentationPlayer player = new PresentationPlayer(animationsGenerator, 33);
        try {
            player.setFrameTick((sender, arguments) ->
            {
                try {
                    arguments.getFrame().save("frame_" + sender.getFrameIndex() + ".png", ImageFormat.Png);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            });
            animationsGenerator.run(presentation.getSlides());
        } finally {
            if (player != null) player.dispose();
        }
    } finally {
        if (animationsGenerator != null) animationsGenerator.dispose();
    }
} finally {
    if (presentation != null) presentation.dispose();
}

Ezután az előállított képkockákat össze lehet állítani egy videóvá. Lásd a Convert PowerPoint to Video részt.

Támogatott animációk és effektusok

Belépés:

Animáció típusa Aspose.Slides PowerPoint
Appear not supported supported
Fade supported supported
Fly In supported supported
Float In supported supported
Split supported supported
Wipe supported supported
Shape supported supported
Wheel supported supported
Random Bars supported supported
Grow & Turn not supported supported
Zoom supported supported
Swivel supported supported
Bounce supported supported

Kiemelés:

Animáció típusa Aspose.Slides PowerPoint
Pulse not supported supported
Color Pulse not supported supported
Teeter supported supported
Spin supported supported
Grow/Shrink not supported supported
Desaturate not supported supported
Darken not supported supported
Lighten not supported supported
Transparency not supported supported
Object Color not supported supported
Complementary Color not supported supported
Line Color not supported supported
Fill Color not supported supported

Kilépés:

Animáció típusa Aspose.Slides PowerPoint
Disappear not supported supported
Fade supported supported
Fly Out supported supported
Float Out supported supported
Split supported supported
Wipe supported supported
Shape supported supported
Random Bars supported supported
Shrink & Turn not supported supported
Zoom supported supported
Swivel supported supported
Bounce supported supported

Mozgás útvonalak:

Animáció típusa Aspose.Slides PowerPoint
Lines supported supported
Arcs supported supported
Turns supported supported
Shapes supported supported
Loops supported supported
Custom Path supported supported

FAQ

Lehetőség van jelszóval védett prezentációk konvertálására?

Igen, az Aspose.Slides lehetővé teszi a password-protected presentations használatát. Az ilyen fájlok feldolgozásakor meg kell adni a megfelelő jelszót, hogy a könyvtár hozzáférhessen a prezentáció tartalmához.

Az Aspose.Slides támogatja a felhasználást felhő megoldásokban?

Igen, az Aspose.Slides integrálható felhőalkalmazásokba és szolgáltatásokba. A könyvtár úgy van tervezve, hogy szerverkörnyezetben működjön, biztosítva a magas teljesítményt és skálázhatóságot a fájlok csoportos feldolgozásához.

Vannak méretkorlátozások a prezentációk konvertálása során?

Az Aspose.Slides képes gyakorlatilag bármilyen méretű prezentációt kezelni. Nagyon nagy fájlok esetén azonban további rendszererőforrásokra lehet szükség, és néha ajánlott a prezentáció optimalizálása a teljesítmény javítása érdekében.