PowerPointをビデオに変換
PowerPointプレゼンテーションをビデオに変換することで、次の利点があります。
- アクセシビリティの向上: プレゼンテーションを開くアプリケーションと比較すると、すべてのデバイス(プラットフォームに関係なく)はデフォルトでビデオプレーヤーを備えているため、ユーザーはビデオを開くまたは再生するのが簡単です。
- 到達範囲の拡大: ビデオを通じて、広範なオーディエンスにリーチし、プレゼンテーションでは退屈に思えるかもしれない情報をターゲットにすることができます。ほとんどの調査や統計によると、人々は他の形態のコンテンツよりもビデオを視聴し、消費することが多く、一般的にそのようなコンテンツを好みます。
Aspose.SlidesにおけるPowerPointからビデオへの変換
Aspose.Slides 22.11で、プレゼンテーションからビデオへの変換をサポートしました。
- Aspose.Slidesを使用して、特定のFPS(フレーム毎秒)に対応する一連のフレーム(プレゼンテーションスライドから)を生成します。
- FFMpegCore(ffmpeg)などのサードパーティユーティリティを使用して、フレームに基づいてビデオを作成します。
PowerPointをビデオに変換
- dotnet add packageコマンドを使用して、Aspose.SlidesおよびFFMpegCoreライブラリをプロジェクトに追加します:
dotnet add package Aspose.Slides.NET --version 22.11.0
を実行します。dotnet add package FFMpegCore --version 4.8.0
を実行します。
- ここからffmpegをダウンロードします。ここ。
- 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())
{
// 笑顔の形を追加し、アニメーションを加えます
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);
}
// 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());
}
ビデオ効果
スライド上のオブジェクトにアニメーションを適用し、スライド間の遷移を使用できます。
アニメーションと遷移はスライドショーをより魅力的で面白くし、ビデオに対しても同じことを行います。前のプレゼンテーションのコードに別のスライドと遷移を追加しましょう:
// 笑顔の形を追加し、アニメーションを加えます
// ...
// 新しいスライドとアニメーション遷移を追加します
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())
{
// テキストとアニメーションを追加します
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("テキストを含むPowerPointプレゼンテーションをビデオに変換"));
Paragraph para3 = new Paragraph();
para3.Portions.Add(new Portion("段落ごとに"));
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;
// フレームをビデオに変換します
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はPresentationAnimationsGeneratorおよびPresentationPlayerクラスを提供します。
PresentationAnimationsGeneratorを使用すると、後で作成されるビデオのフレームサイズをコンストラクタを通じて設定できます。プレゼンテーションのインスタンスを渡すと、Presentation.SlideSize
が使用され、PresentationPlayerが使用するアニメーションを生成します。
アニメーションが生成されると、各後続アニメーションについてNewAnimation
イベントが生成され、IPresentationAnimationPlayerパラメータがあります。後者は、個別のアニメーション用のプレーヤーを表すクラスです。
IPresentationAnimationPlayerと連携するために、Duration(アニメーションの総持続時間)プロパティとSetTimePositionメソッドが使用されます。各アニメーション位置は0からdurationの範囲内で設定され、次にGetFrame
メソッドは、その時点でのアニメーション状態に対応するBitmapを返します。
using (Presentation presentation = new Presentation())
{
// 笑顔の形を追加し、アニメーションを加えます
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;
using (var animationsGenerator = new PresentationAnimationsGenerator(presentation))
{
animationsGenerator.NewAnimation += animationPlayer =>
{
Console.WriteLine($"アニメーションの総持続時間: {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をビデオに変換セクションを参照してください。
サポートされているアニメーションと効果
入口:
アニメーションの種類 | Aspose.Slides | PowerPoint |
---|---|---|
出現 | ![]() |
![]() |
フェード | ![]() |
![]() |
フライイン | ![]() |
![]() |
フロートイン | ![]() |
![]() |
スプリット | ![]() |
![]() |
ワイプ | ![]() |
![]() |
シェイプ | ![]() |
![]() |
ホイール | ![]() |
![]() |
ランダムバー | ![]() |
![]() |
グロウ&ターン | ![]() |
![]() |
ズーム | ![]() |
![]() |
スイベル | ![]() |
![]() |
バウンス | ![]() |
![]() |
強調:
アニメーションの種類 | Aspose.Slides | PowerPoint |
---|---|---|
パルス | ![]() |
![]() |
カラー パルス | ![]() |
![]() |
ティーター | ![]() |
![]() |
スピン | ![]() |
![]() |
成長/縮小 | ![]() |
![]() |
デサチュレート | ![]() |
![]() |
暗くする | ![]() |
![]() |
明るくする | ![]() |
![]() |
透明度 | ![]() |
![]() |
オブジェクトカラー | ![]() |
![]() |
補色 | ![]() |
![]() |
ラインカラー | ![]() |
![]() |
塗りつぶしカラー | ![]() |
![]() |
退出:
アニメーションの種類 | Aspose.Slides | PowerPoint |
---|---|---|
消失 | ![]() |
![]() |
フェード | ![]() |
![]() |
フライアウト | ![]() |
![]() |
フロートアウト | ![]() |
![]() |
スプリット | ![]() |
![]() |
ワイプ | ![]() |
![]() |
シェイプ | ![]() |
![]() |
ランダムバー | ![]() |
![]() |
縮小&ターン | ![]() |
![]() |
ズーム | ![]() |
![]() |
スイベル | ![]() |
![]() |
バウンス | ![]() |
![]() |
モーションパス:
アニメーションの種類 | Aspose.Slides | PowerPoint |
---|---|---|
ライン | ![]() |
![]() |
アーク | ![]() |
![]() |
ターン | ![]() |
![]() |
形状 | ![]() |
![]() |
ループ | ![]() |
![]() |
カスタムパス | ![]() |
![]() |
サポートされているスライド遷移効果
微妙:
アニメーションの種類 | Aspose.Slides | PowerPoint |
---|---|---|
モーフ | ![]() |
![]() |
フェード | ![]() |
![]() |
プッシュ | ![]() |
![]() |
プル | ![]() |
![]() |
ワイプ | ![]() |
![]() |
スプリット | ![]() |
![]() |
リビール | ![]() |
![]() |
ランダムバー | ![]() |
![]() |
シェイプ | ![]() |
![]() |
アンカバー | ![]() |
![]() |
カバー | ![]() |
![]() |
フラッシュ | ![]() |
![]() |
ストリップ | ![]() |
![]() |
エキサイティング:
アニメーションの種類 | Aspose.Slides | PowerPoint |
---|---|---|
フォールオーバー | ![]() |
![]() |
ドレープ | ![]() |
![]() |
カーテン | ![]() |
![]() |
風 | ![]() |
![]() |
プレステージ | ![]() |
![]() |
フラクチャー | ![]() |
![]() |
クラッシュ | ![]() |
![]() |
剥がす | ![]() |
![]() |
ページカール | ![]() |
![]() |
飛行機 | ![]() |
![]() |
折り紙 | ![]() |
![]() |
溶解 | ![]() |
![]() |
チェッカーボード | ![]() |
![]() |
ブラインド | ![]() |
![]() |
時計 | ![]() |
![]() |
波紋 | ![]() |
![]() |
ハニカム | ![]() |
![]() |
グリッター | ![]() |
![]() |
渦 | ![]() |
![]() |
シュレッド | ![]() |
![]() |
スイッチ | ![]() |
![]() |
フリップ | ![]() |
![]() |
ギャラリー | ![]() |
![]() |
キューブ | ![]() |
![]() |
ドア | ![]() |
![]() |
ボックス | ![]() |
![]() |
コーム | ![]() |
![]() |
ズーム | ![]() |
![]() |
ランダム | ![]() |
![]() |
動的コンテンツ:
アニメーションの種類 | Aspose.Slides | PowerPoint |
---|---|---|
パン | ![]() |
![]() |
観覧車 | ![]() |
![]() |
コンベヤ | ![]() |
![]() |
回転 | ![]() |
![]() |
軌道 | ![]() |
![]() |
飛行を通過する | ![]() |
![]() |