C#에서 PPTX를 비디오로 변환

NET Framework, .NET Core, Windows Azure, Mono 또는 Xamarin 플랫폼에서 C# 코드를 사용하여 PowerPoint를 비디오로 변환하기 위한 강력한 크로스 플랫폼 .NET API

Aspose.Slides를 사용하여 PowerPoint를 비디오로 변환

Aspose.Slides for .NET 은 프레젠테이션을 생성, 편집 및 조작하고 PowerPoint 프레젠테이션을 다른 문서로 변환하는 데 사용되는 강력한 .NET 라이브러리입니다. 그리고 비디오. 이 경우 PowerPoint를 비디오로 변환하려면 ffmpegFFMpegCore(무료 NET ffmpeg 래퍼)와 함께 Aspose.Slides를 사용해야 합니다.

이것이 PPTX에서 비디오로의 변환 프로세스가 작동하는 방식입니다. Aspose.Slides는 (프레젠테이션 슬라이드에서) 일련의 프레임을 생성하는 데 사용된 다음 FFMpegCore(ffmpeg)를 사용하여 프레임을 기반으로 비디오를 생성합니다.

PPTX를 비디오로 변환하는 방법

  1. Aspose.Slides for .NETFFMpegcore 설치: 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를 복사하여 붙여넣은 다음 실행합니다.

C#에서 PowerPoint를 비디오로 변환

이 코드를 사용하여 PPTX를 비디오로 변환:

PowerPoint를 비디오로 변환하기 위한 C# 코드


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를 다른 형식의 파일로 변환할 수도 있습니다.