แปลง PPT เป็นวิดีโอ

เมื่อคุณแปลง PowerPoint เป็นวิดีโอ คุณจะได้รับการเข้าถึงที่เพิ่มขึ้นและผู้ชมจำนวนมากขึ้นสำหรับงานนำเสนอหรือเนื้อหาของคุณ รูปแบบวิดีโอ MP4 เป็นรูปแบบไฟล์ที่ได้รับความนิยมอย่างมาก ดังนั้นผู้คนจำนวนมากจะพบว่าการเปิดหรือเล่นวิดีโอของคุณง่ายกว่าเมื่อเทียบกับ [PPT](https ไฟล์://docs.fileformat.com/presentation/ppt/) นอกจากนี้ คนส่วนใหญ่ดูและบริโภควิดีโอมากกว่าเนื้อหารูปแบบอื่น ดังนั้นวิดีโอของคุณจึงน่าจะได้รับผู้ชมจำนวนมากขึ้นเมื่อเทียบกับการนำเสนอ

PowerPoint เป็นวิดีโอใน Java

เมื่อคุณอ่านบทความนี้จบ คุณจะได้เรียนรู้วิธีการแปลง PowerPoint เป็นวิดีโอใน Java

Java API เพื่อแปลง PPT เป็นวิดีโอ

สร้างวิดีโอใน PowerPoint

ในการแปลงงานนำเสนอ PowerPoint เป็นวิดีโอโดยทางโปรแกรม คุณต้องมี:

  • API เพื่อสร้างชุดเฟรมจากสไลด์นำเสนอ เราขอแนะนำ Aspose.Slides for Java Aspose.Slides for Java เป็น API ยอดนิยมสำหรับการสร้าง แก้ไข แปลง และจัดการงานนำเสนอ PowerPoint (โดยไม่ต้องใช้ Microsoft PowerPoint หรือ Office) หากต้องการติดตั้ง Aspose.Slides for 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 คุณสมบัติ โปรดดูเอกสารประกอบ/). หากคุณมีคำถาม คุณสามารถโพสต์ได้ที่ฟอรัม

ดูสิ่งนี้ด้วย