Converti PPT in video in C#

Potente API .NET multipiattaforma per convertire PowerPoint in video utilizzando il codice C# su piattaforme NET Framework, .NET Core, Windows Azure, Mono o Xamarin

Converti PowerPoint in video utilizzando Aspose.Slides

Aspose.Slides per .NET è una potente libreria .NET utilizzata per creare, modificare e manipolare presentazioni e anche convertire presentazioni PowerPoint in altri documenti e video. In questo caso, per convertire PowerPoint in video, devi utilizzare Aspose.Slides insieme a ffmpeg e FFMpegCore (un wrapper NET ffmpeg gratuito).

Ecco come funziona il processo di conversione da PPT a video: Aspose.Slides viene utilizzato per generare un set di frame (dalle diapositive della presentazione) e quindi FFMpegCore (ffmpeg) viene utilizzato per creare un video basato sui frame.

Come convertire PPT in video

  1. Installa Aspose.Slides per .NET e FFMpegcore: esegui dotnet add package Aspose.Slides.NET --version 22.12.0 e quindi esegui dotnet add package FFMpegCore --version 4.8.0

  2. Scarica ffmpeg qui.

  3. FFMpegCore richiede di specificare il percorso del file ffmpeg scaricato (ad es. estratto in “C:\tools\ffmpeg”): GlobalFFOptions.Configure(new FFOptions { BinaryFolder = @"c:\tools\ffmpeg\bin",} );

  4. Copiare, incollare e quindi eseguire il codice da PowerPoint a video.

Converti PowerPoint in video in C#

Usa questo codice per convertire PPT in video:

Codice C# per convertire PowerPoint in video


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

}

Altre conversioni supportate

Puoi anche convertire PowerPoint in file in altri formati