המרת PPT לווידאו

כאשר אתה ממיר PowerPoint לווידאו, אתה מקבל נגישות מוגברת וקהל גדול יותר עבור המצגת או התוכן שלך. פורמט הווידאו MP4 הוא פורמט קובץ פופולרי להפליא, כך שיותר אנשים ימצאו שקל יותר לפתוח או להפעיל את הסרטון שלך בהשוואה ל-[PPT](https קובץ ://docs.fileformat.com/presentation/ppt/). יתר על כן, רוב האנשים צופים וצורכים וידאו יותר מצורות תוכן אחרות, כך שהסרטון שלך צפוי לקבל קהל גדול יותר בהשוואה למצגת.

PowerPoint לווידאו ב-Java

עד שתסיים לקרוא מאמר זה, תלמד כיצד להמיר PowerPoint לווידאו ב-Java.

ממשקי API של Java להמרת PPT לווידאו

צור וידאו ב- PowerPoint

כדי להמיר מצגת PowerPoint לסרטון באופן פרוגרמטי, אתה צריך:

  • ממשק API ליצירת סט פריימים משקופיות המצגת. אנו ממליצים על Aspose.Slides עבור Java. Aspose.Slides עבור Java for הוא ממשק API פופולרי ליצירה, עריכה, המרה וטיפול במצגות PowerPoint (ללא Microsoft PowerPoint או Office). להתקנת Aspose.Slides עבור Java, ראה התקנה.
  • ועוד API ליצירת סרטון על סמך הפריימים שנוצרו. אנו ממליצים על ffmpeg (עבור Java).

מידע: Aspose פיתחה ממיר PowerPoint לווידאו בחינם המאפשר לך ליצור סרטונים מדהימים ממצגות. ממיר זה הוא בעצם יישום חי של תהליך המרת PowerPoint לווידאו.

המרת PPT לווידאו ב-Java

  1. הוסף את זה לקובץ POM שלך:
   <dependency>
     <groupId>net.bramp.ffmpeg</groupId>
     <artifactId>ffmpeg</artifactId>
     <version>0.7.0</version>
   </dependency>
  1. הורד את ffmpeg כאן.

  2. הפעל את קוד Java של PowerPoint לווידאו.

קוד Java זה מראה לך כיצד להמיר PPT לווידאו:

Presentation presentation = new Presentation();
try {
    // מוסיף צורת חיוך ולאחר מכן מחייה אותו
    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();
    }

    // הגדר את התיקיה הבינאריים של ffmpeg. ראה דף זה: 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 מאפשר לך להחיל אנימציות על תוכן המצגות שלך וגם להשתמש במעברים בין שקופיות. האפקטים הללו הופכים מצגת (במיוחד בצורה של מצגת) למושכת ומעניינת יותר. כאשר אתה ממיר מצגת PowerPoint לווידאו, הגיוני להשתמש באפקטים דומים בסרטון המתקבל ו-Aspose.Slides מאפשר לך לעשות בדיוק את זה.

כדי להדגים את השימוש באפקטים והנפשות בסרטון, בואו נוסיף שקופית נוספת ונעבור לקוד של המצגת בסעיף הקודם בצורה זו:

// מוסיף צורת חיוך ומפעיל אותו

// ...

// מוסיף שקופית חדשה ומעבר מונפש

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

לאחר מכן אנו מבצעים הנפשה של פסקאות על אובייקטים כדי לגרום לאובייקטים הללו להופיע בזה אחר זה (עם ההשהיה בין ההופעות מוגדר לשניה):

Presentation presentation = new Presentation();
try {
    // מוסיף טקסט ואנימציות
    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());
                    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();
    }

    // הגדר את התיקיה הבינאריים של ffmpeg. ראה דף זה: 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 ללא הגבלה, אנו ממליצים לך לקבל רישיון זמני בחינם.

סיכום

אנו מאמינים שאתה יודע כעת להמיר PPT לווידאו וגם ליישם אנימציות, מעברים ואפקטים אחרים בעבודה שלך.

למידע נוסף על Aspose.Slides features, עיין בתיעוד/). אם יש לך שאלות, תוכל לפרסם אותן ב[פורום] שלנו (https://forum.aspose.com/c/slides/).

ראה גם