Convertir PPT a video en C#

Potente API .NET multiplataforma para convertir PowerPoint a video usando código C# en plataformas NET Framework, .NET Core, Windows Azure, Mono o Xamarin

Convierta PowerPoint a video usando Aspose.Slides

Aspose.Slides for .NET es una poderosa biblioteca .NET que se usa para crear, editar y manipular presentaciones y también convertir presentaciones de PowerPoint en otros documentos y videos En este caso, para convertir PowerPoint a video, debe usar Aspose.Slides junto con ffmpeg y FFMpegCore (un contenedor NET ffmpeg gratuito).

Así es como funciona el proceso de conversión de PPT a video: Aspose.Slides se usa para generar un conjunto de cuadros (a partir de las diapositivas de la presentación) y luego se usa FFMpegCore (ffmpeg) para crear un video basado en los cuadros.

Cómo convertir PPT a video

  1. Instale Aspose.Slides para .NET y FFMPegcore: Ejecute dotnet add package Aspose.Slides.NET --version 22.12.0 y luego ejecute dotnet add package FFMpegCore --version 4.8.0

  2. Descarga ffmpeg aquí.

  3. FFMpegCore requiere que especifique la ruta al ffmpeg descargado (p. ej., extraído a “C:\tools\ffmpeg”): GlobalFFOptions.Configure(new FFOptions { BinaryFolder = @"c:\tools\ffmpeg\bin",} );

  4. Copie, pegue y luego ejecute el código de PowerPoint a video.

Convertir PowerPoint a video en C#

Use este código para convertir PPT a video:

Código C# para convertir PowerPoint a 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());

}

Otras conversiones admitidas

También puede convertir PowerPoint a archivos en otros formatos