Create video in PowerPoint

A video derived from a PowerPoint presentation is quite effective at showcasing a data visualization and marketing a product. It is also quite proficient at delivering different kinds of messages to a wide audience category. Given the benefits associated with a real video playback over a standard presentation, it makes sense to convert PPT to video in many scenarios.

Convert PPT to Video in C#

In this article, we intend to walk you through an operation on performing the PPT to MP4 conversion task programmatically. See how to convert PPT to video in C# below.

C# APIs to Convert PPT to Video

Convert PPT to video

A video consists of frames, so the PowerPoint to video conversion process requires you to do two things:

  • Generate a set of frames based on the presentation slides. Aspose.Slides for .NET comes in handy here. To install Aspose.Slides for .NET, see Installation.

  • create a video based on the generated frames. This is where ffmpeg (and ffmpeg core for .NET) comes in—download ffmpeg here.

Info: Aspose provides a free PowerPoint to video converter that allows to transform PowerPoint presentations into video. You may want to see this converter because it is a live implementation of the process here.

Convert PPT to Video in C#

  1. Add Aspose.Slides for .NET and FFMpegCore to your project through the dotnet add package command:

    • To add Aspose.Slides for .NET, run dotnet add package Aspose.Slides.NET --version 22.11.0
    • To add FFMpegCore, run dotnet add package FFMpegCore --version 4.8.0
  2. Specify the path to the ffmpeg you got earlier (for example, you extracted it to “C:\tools\ffmpeg”) this way: GlobalFFOptions.Configure(new FFOptions { BinaryFolder = @"c:\tools\ffmpeg\bin",} );

  3. Run the code for converting PowerPoint to 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());
}

Apply Effects and Animations in Video

Presentations containing transitions and animations are generally more engaging and interesting than those without those effects. The same principle applies to videos—a video that simply slides in quick succession just won’t cut it sometimes.

Aspose.Slides supports common transitions and animations, so you can apply and use those effects in your video. Assuming we continue with the code from the previous section, we can another slide and a transition this way:

// Adds a smile shape and animates it
// ...
// Adds a new slide and animated transition
ISlide newSlide = presentation.Slides.AddEmptySlide(presentation.Slides[0].LayoutSlide);
newSlide.Background.Type = BackgroundType.OwnBackground;
newSlide.Background.FillFormat.FillType = FillType.Solid;
newSlide.Background.FillFormat.SolidFillColor.Color = Color.Indigo;
newSlide.SlideShowTransition.Type = TransitionType.Push;

Besides animations for slides, Aspose.Slides allows you to add animations for texts. This way, you get to animate paragraphs on objects to make them appear one after the other (with the delay set to one second, for example):

using System.Collections.Generic;
using Aspose.Slides.Export;
using Aspose.Slides;
using FFMpegCore;
using Aspose.Slides.Animation;
using (Presentation presentation = new Presentation())
{
// Adds text and animations
IAutoShape autoShape = presentation.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 210, 120, 300, 300);
Paragraph para1 = new Paragraph();
para1.Portions.Add(new Portion("Aspose Slides for .NET"));
Paragraph para2 = new Paragraph();
para2.Portions.Add(new Portion("convert PowerPoint Presentation with text to video"));
Paragraph para3 = new Paragraph();
para3.Portions.Add(new Portion("paragraph by paragraph"));
autoShape.TextFrame.Paragraphs.Add(para1);
autoShape.TextFrame.Paragraphs.Add(para2);
autoShape.TextFrame.Paragraphs.Add(para3);
autoShape.TextFrame.Paragraphs.Add(new Paragraph());
IEffect effect = presentation.Slides[0].Timeline.MainSequence.AddEffect(para1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
IEffect effect2 = presentation.Slides[0].Timeline.MainSequence.AddEffect(para2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
IEffect effect3 = presentation.Slides[0].Timeline.MainSequence.AddEffect(para3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
IEffect effect4 = presentation.Slides[0].Timeline.MainSequence.AddEffect(para3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
effect.Timing.TriggerDelayTime = 1f;
effect2.Timing.TriggerDelayTime = 1f;
effect3.Timing.TriggerDelayTime = 1f;
effect4.Timing.TriggerDelayTime = 1f;
// Converts frames to video
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("text_animation.webm", Fps, frames.Select(frame => ImageInfo.FromPath(frame)).ToArray());
}

Get a Free License

Looking to try out Aspose.Slides features without limitations? Get a free temporary license.

Conclusion

At this point, we believe you now know how to convert PowerPoint PPT to simple videos or more complicated videos with animations, transitions, and other effects.

To learn more about Aspose.Slides features, see our documentation. If you have questions, you can post them on our forum.

See Also