แปลง PPTX เป็นวิดีโอใน C#

.NET API ข้ามแพลตฟอร์มที่มีประสิทธิภาพสำหรับการแปลง PowerPoint เป็นวิดีโอโดยใช้โค้ด C# บน NET Framework, .NET Core, Windows Azure, Mono หรือ Xamarin Platforms

แปลง PowerPoint เป็นวิดีโอโดยใช้ Aspose.Slides

Aspose.Slides สำหรับ .NET เป็นไลบรารี .NET อันทรงพลังที่ใช้สร้าง แก้ไข และจัดการงานนำเสนอ และยังแปลงงานนำเสนอ PowerPoint เป็นเอกสารอื่นๆ และวิดีโอ ในกรณีนี้ ในการแปลง PowerPoint เป็นวิดีโอ คุณต้องใช้ Aspose.Slides ควบคู่ไปกับ ffmpeg และ FFMpegCore (ตัวตัด FFmpeg NET ฟรี)

นี่เป็นวิธีการทำงานของกระบวนการแปลง PPTX เป็นวิดีโอ: Aspose.Slides ใช้เพื่อสร้างชุดของเฟรม (จากสไลด์การนำเสนอ) จากนั้นใช้ FFMpegCore (ffmpeg) เพื่อสร้างวิดีโอตามเฟรม

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

  1. ติดตั้ง Aspose.Slides สำหรับ .NET และ FFMpegcore: เรียกใช้ dotnet add package Aspose.Slides.NET --version 22.12.0 จากนั้นเรียกใช้ dotnet add package FFMpegCore --version 4.8.0

  2. ดาวน์โหลด ffmpeg ที่นี่

  3. FFMpegCore ต้องการให้คุณระบุพาธไปยัง ffmpeg ที่ดาวน์โหลดมา (เช่น แยกเป็น “C:\tools\ffmpeg”): GlobalFFOptions.Configure(new FFOptions { BinaryFolder = @"c:\tools\ffmpeg\bin",} );

  4. คัดลอก วาง แล้วเรียกใช้โค้ด PowerPoint เป็นวิดีโอ

แปลง PowerPoint เป็นวิดีโอใน C#

ใช้รหัสนี้เพื่อแปลง PPTX เป็นวิดีโอ:

รหัส C# สำหรับแปลง PowerPoint เป็นวิดีโอ


using System.Collections.Generic;
using Aspose.Slides;
using FFMpegCore; // Will use FFmpeg binaries we extracted to "c:\tools\ffmpeg" before
using Aspose.Slides.Animation;
using (Presentation presentation = new Presentation())

{
    // Adds a smile shape and then animates it
    IAutoShape smile = presentation.Slides[0].Shapes.AddAutoShape(ShapeType.SmileyFace, 110, 20, 500, 500);
    IEffect effectIn = presentation.Slides[0].Timeline.MainSequence.AddEffect(smile, EffectType.Fly, EffectSubtype.TopLeft, EffectTriggerType.AfterPrevious);
    IEffect effectOut = presentation.Slides[0].Timeline.MainSequence.AddEffect(smile, EffectType.Fly, EffectSubtype.BottomRight, EffectTriggerType.AfterPrevious);
    effectIn.Timing.Duration = 2f;
    effectOut.PresetClassType = EffectPresetClassType.Exit;

   const int Fps = 33;
   List<string> frames = new List<string>();

   using (var animationsGenerator = new PresentationAnimationsGenerator(presentation))
    using (var player = new PresentationPlayer(animationsGenerator, Fps))
    {
        player.FrameTick += (sender, args) =>
        {
            string frame = $"frame_{(sender.FrameIndex):D4}.png";
            args.GetFrame().Save(frame);
            frames.Add(frame);
        };
        animationsGenerator.Run(presentation.Slides);
    }

    // Configure ffmpeg binaries folder. See this page: https://github.com/rosenbjerg/FFMpegCore#installation
    GlobalFFOptions.Configure(new FFOptions { BinaryFolder = @"c:\tools\ffmpeg\bin", });
    // Converts frames to webm video
    FFMpeg.JoinImageSequence("smile.webm", Fps, frames.Select(frame => ImageInfo.FromPath(frame)).ToArray());

}

การแปลงอื่น ๆ ที่รองรับ

คุณยังสามารถแปลง PowerPoint เป็นไฟล์ในรูปแบบอื่นๆ