修复自定义导出问题
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using FFMpegCore;
|
using FFMpegCore;
|
||||||
using FFMpegCore.Pipes;
|
using FFMpegCore.Pipes;
|
||||||
|
using SFML.Graphics;
|
||||||
using SFML.System;
|
using SFML.System;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -63,6 +64,22 @@ namespace Spine.Exporters
|
|||||||
else options.WithCustomArgument("-vf unpremultiply=inplace=1");
|
else options.WithCustomArgument("-vf unpremultiply=inplace=1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取的一帧, 结果是预乘的
|
||||||
|
/// </summary>
|
||||||
|
protected override SFMLImageVideoFrame GetFrame(SpineObject[] spines)
|
||||||
|
{
|
||||||
|
// BUG: 也许和 SFML 多线程或者 FFmpeg 调用有关, 当渲染线程也在运行的时候此处并行渲染会导致和 SFML 有关的内容都卡死
|
||||||
|
// 不知道为什么用 FFmpeg 必须临时创建 RenderTexture, 否则无法正常渲染, 会导致画面帧丢失
|
||||||
|
using var tex = new RenderTexture(_renderTexture.Size.X, _renderTexture.Size.Y);
|
||||||
|
using var view = _renderTexture.GetView();
|
||||||
|
tex.SetView(view);
|
||||||
|
tex.Clear(_backgroundColorPma);
|
||||||
|
foreach (var sp in spines.Reverse()) tex.Draw(sp);
|
||||||
|
tex.Display();
|
||||||
|
return new(tex.Texture.CopyToImage());
|
||||||
|
}
|
||||||
|
|
||||||
public override void Export(string output, CancellationToken ct, params SpineObject[] spines)
|
public override void Export(string output, CancellationToken ct, params SpineObject[] spines)
|
||||||
{
|
{
|
||||||
var videoFramesSource = new RawVideoPipeSource(GetFrames(spines, output, ct)) { FrameRate = _fps };
|
var videoFramesSource = new RawVideoPipeSource(GetFrames(spines, output, ct)) { FrameRate = _fps };
|
||||||
|
|||||||
Reference in New Issue
Block a user