.NETでPowerPointプレゼンテーションを動画に変換する
概要
PowerPoint または OpenDocument プレゼンテーションを動画に変換することで、次の利点が得られます。
アクセシビリティの向上: プラットフォームに関係なく、すべてのデバイスにはデフォルトで動画プレーヤーが搭載されているため、従来のプレゼンテーションアプリケーションよりも動画の再生や閲覧が容易です。
リーチの拡大: 動画はより大きなオーディエンスに届きやすく、情報を魅力的な形式で提示できます。調査や統計によれば、ユーザーは他の形式よりも動画コンテンツの視聴・消費を好むため、メッセージのインパクトが高まります。
Aspose.Slides for .NET では、プレゼンテーションを動画に変換する機能を実装しています。
- Aspose.Slides for .NET を使用して、指定したフレームレート (FPS) でスライドからフレームを生成します。
- その後、ffmpeg などのサードパーティーツールでこれらのフレームを動画にまとめます。
PowerPoint プレゼンテーションを動画に変換する方法
dotnet add packageコマンドで Aspose.Slides と FFMpegCore ライブラリをプロジェクトに追加します:dotnet add package Aspose.Slides.NET --version 22.11.0dotnet add package FFMpegCore --version 4.8.0
- ffmpeg を here からダウンロードします。
- FFMpegCore では、ダウンロードした ffmpeg のパスを指定する必要があります (例: 「C:\tools\ffmpeg」に展開した場合):
GlobalFFOptions.Configure(new FFOptions { BinaryFolder = @"c:\tools\ffmpeg\bin" });
- PowerPoint から動画への変換コードを実行します。
以下の C# コードは、シェイプと 2 つのアニメーション効果を含むプレゼンテーションを動画に変換する方法を示しています:
using System.Collections.Generic;
using Aspose.Slides;
using FFMpegCore; // 以前に C:\tools\ffmpeg に抽出した FFmpeg バイナリを使用します。
using Aspose.Slides.Animation;
using (Presentation presentation = new Presentation())
{
ISlide slide = presentation.Slides[0];
// スマイルシェイプを追加してからアニメーションを付けます。
IAutoShape smile = slide.Shapes.AddAutoShape(ShapeType.SmileyFace, 110, 20, 500, 500);
IEffect effectIn = slide.Timeline.MainSequence.AddEffect(
smile, EffectType.Fly, EffectSubtype.TopLeft, EffectTriggerType.AfterPrevious);
IEffect effectOut = slide.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);
}
// ffmpeg バイナリフォルダーを設定します。こちらのページをご覧ください: https://github.com/rosenbjerg/FFMpegCore#installation
GlobalFFOptions.Configure(new FFOptions { BinaryFolder = @"c:\tools\ffmpeg\bin" });
// フレームを webm ビデオに変換します。
FFMpeg.JoinImageSequence("smile.webm", Fps, frames.Select(frame => ImageInfo.FromPath(frame)).ToArray());
}
動画エフェクト
Aspose.Slides for .NET を使用して PowerPoint プレゼンテーションを動画に変換する際、さまざまな動画エフェクトを適用して出力の視覚品質を向上させることができます。これらのエフェクトにより、スムーズなトランジションやアニメーション、その他のビジュアル要素を動画に組み込むことが可能です。本セクションでは利用可能な動画エフェクトオプションとその適用方法を説明します。
アニメーションやトランジションはスライドショーをより魅力的にしますが、動画でも同様です。前述のプレゼンテーションに別のスライドとトランジションを追加するコード例は次のとおりです:
// スマイルシェイプを追加し、アニメーションを付けます。
// ...
// 新しいスライドとアニメーション付きのトランジションを追加します。
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;
Aspose.Slides はテキストアニメーションもサポートしています。以下の例では、オブジェクト上の段落を 1 秒の遅延で順に表示するアニメーションを実装しています:
using System.Collections.Generic;
using Aspose.Slides.Export;
using Aspose.Slides;
using FFMpegCore;
using Aspose.Slides.Animation;
using (Presentation presentation = new Presentation())
{
ISlide slide = presentation.Slides[0];
// テキストとアニメーションを追加します。
IAutoShape autoShape = slide.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 a 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 effect1 = slide.Timeline.MainSequence.AddEffect(
para1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
IEffect effect2 = slide.Timeline.MainSequence.AddEffect(
para2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
IEffect effect3 = slide.Timeline.MainSequence.AddEffect(
para3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
IEffect effect4 = slide.Timeline.MainSequence.AddEffect(
para3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
effect1.Timing.TriggerDelayTime = 1f;
effect2.Timing.TriggerDelayTime = 1f;
effect3.Timing.TriggerDelayTime = 1f;
effect4.Timing.TriggerDelayTime = 1f;
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);
}
// ffmpeg バイナリ フォルダーを設定します。こちらのページをご覧ください: https://github.com/rosenbjerg/FFMpegCore#installation
GlobalFFOptions.Configure(new FFOptions { BinaryFolder = @"c:\tools\ffmpeg\bin" });
// フレームを webm ビデオに変換します。
FFMpeg.JoinImageSequence("text_animation.webm", Fps, frames.Select(frame => ImageInfo.FromPath(frame)).ToArray());
}
動画変換クラス
PowerPoint から動画への変換タスクを実現するために、Aspose.Slides for .NET は PresentationAnimationsGenerator と PresentationPlayer クラスを提供しています。
PresentationAnimationsGenerator はコンストラクタで動画のフレームサイズと FPS (1 秒あたりのフレーム数) を設定できます。プレゼンテーション インスタンスを渡すと、その Presentation.SlideSize が使用され、生成されたアニメーションは PresentationPlayer が利用します。
アニメーションが生成されると、各アニメーションごとに NewAnimation イベントが発生し、IPresentationAnimationPlayer パラメータが渡されます。このクラスは個々のアニメーション用プレーヤーを表します。
IPresentationAnimationPlayer を操作するには、全体の再生時間を示す Duration プロパティと、再生位置を設定する SetTimePosition メソッドを使用します。位置は 0 から Duration の範囲で指定でき、GetFrame メソッドは指定時点のアニメーション状態を表す Bitmap を返します。
using (Presentation presentation = new Presentation())
{
ISlide slide = presentation.Slides[0];
// スマイルシェイプを追加し、アニメーションを付けます。
IAutoShape smile = slide.Shapes.AddAutoShape(ShapeType.SmileyFace, 110, 20, 500, 500);
IEffect effectIn = slide.Timeline.MainSequence.AddEffect(
smile, EffectType.Fly, EffectSubtype.TopLeft, EffectTriggerType.AfterPrevious);
IEffect effectOut = slide.Timeline.MainSequence.AddEffect(
smile, EffectType.Fly, EffectSubtype.BottomRight, EffectTriggerType.AfterPrevious);
effectIn.Timing.Duration = 2f;
effectOut.PresetClassType = EffectPresetClassType.Exit;
using (var animationsGenerator = new PresentationAnimationsGenerator(presentation))
{
animationsGenerator.NewAnimation += animationPlayer =>
{
Console.WriteLine($"Total animation duration: {animationPlayer.Duration}");
animationPlayer.SetTimePosition(0); // 初期アニメーション状態。
Bitmap bitmap = animationPlayer.GetFrame(); // 初期アニメーション状態のビットマップ。
animationPlayer.SetTimePosition(animationPlayer.Duration); // アニメーションの最終状態。
Bitmap lastBitmap = animationPlayer.GetFrame(); // アニメーションの最後のフレーム。
lastBitmap.Save("last.png");
};
}
}
すべてのアニメーションを同時に再生させるには、PresentationPlayer クラスを使用します。このクラスはコンストラクタで PresentationAnimationsGenerator インスタンスと FPS を受け取り、FrameTick イベントを介して全アニメーションを再生します:
using (Presentation presentation = new Presentation("animated.pptx"))
{
using (var animationsGenerator = new PresentationAnimationsGenerator(presentation))
using (var player = new PresentationPlayer(animationsGenerator, 33))
{
player.FrameTick += (sender, args) =>
{
args.GetFrame().Save($"frame_{sender.FrameIndex}.png");
};
animationsGenerator.Run(presentation.Slides);
}
}
生成されたフレームは動画にコンパイルできます。詳細は PowerPoint プレゼンテーションを動画に変換する セクションをご参照ください。
サポートされているアニメーションとエフェクト
PowerPoint プレゼンテーションを動画に変換する際、出力でサポートされるアニメーションとエフェクトを把握しておくことが重要です。Aspose.Slides はフェード、フライイン、ズーム、スピンなどの一般的な入場、退出、強調エフェクトを幅広くサポートしています。ただし、一部の高度なカスタムアニメーションは完全に保持されないか、動画内で異なる形で表現される場合があります。本節ではサポート対象のアニメーションとエフェクトをまとめています。
入場 (Entrance):
| アニメーション タイプ | Aspose.Slides | PowerPoint |
|---|---|---|
| Appear | ![]() |
![]() |
| Fade | ![]() |
![]() |
| Fly In | ![]() |
![]() |
| Float In | ![]() |
![]() |
| Split | ![]() |
![]() |
| Wipe | ![]() |
![]() |
| Shape | ![]() |
![]() |
| Wheel | ![]() |
![]() |
| Random Bars | ![]() |
![]() |
| Grow & Turn | ![]() |
![]() |
| Zoom | ![]() |
![]() |
| Swivel | ![]() |
![]() |
| Bounce | ![]() |
![]() |
強調 (Emphasis):
| アニメーション タイプ | Aspose.Slides | PowerPoint |
|---|---|---|
| Pulse | ![]() |
![]() |
| Color Pulse | ![]() |
![]() |
| Teeter | ![]() |
![]() |
| Spin | ![]() |
![]() |
| Grow/Shrink | ![]() |
![]() |
| Desaturate | ![]() |
![]() |
| Darken | ![]() |
![]() |
| Lighten | ![]() |
![]() |
| Transparency | ![]() |
![]() |
| Object Color | ![]() |
![]() |
| Complementary Color | ![]() |
![]() |
| Line Color | ![]() |
![]() |
| Fill Color | ![]() |
![]() |
退出 (Exit):
| アニメーション タイプ | Aspose.Slides | PowerPoint |
|---|---|---|
| Disappear | ![]() |
![]() |
| Fade | ![]() |
![]() |
| Fly Out | ![]() |
![]() |
| Float Out | ![]() |
![]() |
| Split | ![]() |
![]() |
| Wipe | ![]() |
![]() |
| Shape | ![]() |
![]() |
| Random Bars | ![]() |
![]() |
| Shrink & Turn | ![]() |
![]() |
| Zoom | ![]() |
![]() |
| Swivel | ![]() |
![]() |
| Bounce | ![]() |
![]() |
モーション パス (Motion Paths):
| アニメーション タイプ | Aspose.Slides | PowerPoint |
|---|---|---|
| Lines | ![]() |
![]() |
| Arcs | ![]() |
![]() |
| Turns | ![]() |
![]() |
| Shapes | ![]() |
![]() |
| Loops | ![]() |
![]() |
| Custom Path | ![]() |
![]() |
サポートされているスライド トランジション エフェクト
スライド トランジション エフェクトは、動画内でスライド間の切り替えをスムーズかつ視覚的に魅力的にする上で重要です。Aspose.Slides for .NET は、元のプレゼンテーションの流れとスタイルを維持するために、一般的に使用されるさまざまなトランジション エフェクトをサポートしています。本節では、変換プロセス中にサポートされるトランジション エフェクトを紹介します。
サブティル (Subtle):
| アニメーション タイプ | Aspose.Slides | PowerPoint |
|---|---|---|
| Morph | ![]() |
![]() |
| Fade | ![]() |
![]() |
| Push | ![]() |
![]() |
| Pull | ![]() |
![]() |
| Wipe | ![]() |
![]() |
| Split | ![]() |
![]() |
| Reveal | ![]() |
![]() |
| Random Bars | ![]() |
![]() |
| Shape | ![]() |
![]() |
| Uncover | ![]() |
![]() |
| Cover | ![]() |
![]() |
| Flash | ![]() |
![]() |
| Strips | ![]() |
![]() |
エキサイティング (Exciting):
| アニメーション タイプ | Aspose.Slides | PowerPoint |
|---|---|---|
| Fall Over | ![]() |
![]() |
| Drape | ![]() |
![]() |
| Curtains | ![]() |
![]() |
| Wind | ![]() |
![]() |
| Prestige | ![]() |
![]() |
| Fracture | ![]() |
![]() |
| Crush | ![]() |
![]() |
| Peel Off | ![]() |
![]() |
| Page Curl | ![]() |
![]() |
| Airplane | ![]() |
![]() |
| Origami | ![]() |
![]() |
| Dissolve | ![]() |
![]() |
| Checkerboard | ![]() |
![]() |
| Blinds | ![]() |
![]() |
| Clock | ![]() |
![]() |
| Ripple | ![]() |
![]() |
| Honeycomb | ![]() |
![]() |
| Glitter | ![]() |
![]() |
| Vortex | ![]() |
![]() |
| Shred | ![]() |
![]() |
| Switch | ![]() |
![]() |
| Flip | ![]() |
![]() |
| Gallery | ![]() |
![]() |
| Cube | ![]() |
![]() |
| Doors | ![]() |
![]() |
| Box | ![]() |
![]() |
| Comb | ![]() |
![]() |
| Zoom | ![]() |
![]() |
| Random | ![]() |
![]() |
ダイナミック コンテンツ (Dynamic Content):
| アニメーション タイプ | Aspose.Slides | PowerPoint |
|---|---|---|
| Pan | ![]() |
![]() |
| Ferris Wheel | ![]() |
![]() |
| Conveyor | ![]() |
![]() |
| Rotate | ![]() |
![]() |
| Orbit | ![]() |
![]() |
| Fly Through | ![]() |
![]() |
FAQ
パスワードで保護されたプレゼンテーションを変換できますか?
はい、Aspose.Slides for .NET はパスワード保護されたプレゼンテーションの取り扱いをサポートしています。処理時に正しいパスワードを指定すれば、ライブラリはプレゼンテーションの内容にアクセスできます。
Aspose.Slides for .NET はクラウド ソリューションでの使用をサポートしていますか?
はい、Aspose.Slides for .NET はクラウド アプリケーションやサービスに組み込むことができます。サーバー環境での高パフォーマンスとスケーラビリティを念頭に設計されており、バッチ処理に適しています。
変換時にプレゼンテーションのサイズ制限はありますか?
Aspose.Slides for .NET は実質的に任意のサイズのプレゼンテーションを処理できます。ただし、非常に大きなファイルの場合は追加のシステムリソースが必要になることがあり、パフォーマンス向上のためにプレゼンテーションを最適化することが推奨される場合があります。

