コミットを比較
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
85451eb49a
|
||
|
|
e2e8caf836
|
||
|
|
e6f3bc6557
|
||
|
|
ad1d6cdd50
|
||
|
|
bf6de65f3c
|
||
|
|
4f2e566ab8
|
||
|
|
9352e8e2c3
|
||
|
|
c377663165
|
検索条件に一致するファイルはありません
@@ -1,5 +1,5 @@
|
||||
========================================
|
||||
ProxyForge for YMM4 v2.0.0
|
||||
ProxyForge for YMM4 v2.0.2
|
||||
========================================
|
||||
YukkuriMovieMaker4(YMM4)上で動作する、編集の間だけ使う解像度の低い
|
||||
動画ファイルを作り、プレビューでは元の動画の代わりにそれを読み込む
|
||||
|
||||
@@ -187,6 +187,20 @@ public sealed class ProxyEncoderTests
|
||||
Assert.False(File.Exists(workspace.OutputPath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AnOutputThatCannotBeOpenedIsReportedAsAnFFmpegFailure()
|
||||
{
|
||||
Ymm4TestEnvironment.Require();
|
||||
using var workspace = new Workspace();
|
||||
var encoder = workspace.CreateEncoder(640, 360, 30, 1, 10);
|
||||
using var session = await encoder.OpenAsync(workspace.Request(50), TestContext.Current.CancellationToken);
|
||||
var missing = Path.Combine(workspace.Path, "missing", "proxy.mp4");
|
||||
|
||||
var exception = await Assert.ThrowsAsync<ProxyEncodeException>(() => session.EncodeAsync(0, 10, missing, null, TestContext.Current.CancellationToken));
|
||||
|
||||
Assert.Equal(ProxyEncodeFailure.FFmpegFailed, exception.Failure);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ASoftEdgeIsNotMistakenForTransparency()
|
||||
{
|
||||
@@ -474,6 +488,44 @@ public sealed class ProxyEncoderTests
|
||||
Assert.IsType<IOException>(failure.InnerException);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RunAsyncReportsTheExitOfFFmpegThatStoppedReadingTheInput()
|
||||
{
|
||||
Ymm4TestEnvironment.Require();
|
||||
using var workspace = new Workspace();
|
||||
var missing = Path.Combine(workspace.Path, "missing", "proxy.mp4");
|
||||
Exception? failure = null;
|
||||
|
||||
var result = await FFmpegProcessRunner.RunAsync(
|
||||
Ymm4TestEnvironment.FFmpegPath,
|
||||
arguments =>
|
||||
{
|
||||
var request = new FFmpegEncodeRequest(missing, 32, 32, new FrameRate(30, 1), 100_000, 1, SoftwareEncoder);
|
||||
FFmpegArguments.WriteEncode(arguments, in request);
|
||||
},
|
||||
workspace.Path,
|
||||
(destination, cancellationToken) => Task.Run(() =>
|
||||
{
|
||||
var frame = new byte[32 * 32 * 4];
|
||||
try
|
||||
{
|
||||
for (var index = 0; index < 1024; index++)
|
||||
destination.Write(frame);
|
||||
}
|
||||
catch (IOException exception)
|
||||
{
|
||||
failure = exception;
|
||||
throw;
|
||||
}
|
||||
}, cancellationToken),
|
||||
ProcessPriorityClass.BelowNormal,
|
||||
TestContext.Current.CancellationToken);
|
||||
|
||||
Assert.IsType<IOException>(failure);
|
||||
Assert.False(result.IsSuccess);
|
||||
Assert.Contains(missing, result.Diagnostics);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RunAsyncRethrowsOtherFailuresOfTheInputWriterUnchanged()
|
||||
{
|
||||
|
||||
@@ -203,11 +203,13 @@ public sealed class ProxyVideoSourceTests : IDisposable
|
||||
var source = CreateSource();
|
||||
var entry = Register(source, 0, 1, 2);
|
||||
using var wrapper = CreateWrapper(source, entry, null);
|
||||
var lastTickOfFrame299 = new FrameRate(30, 1).GetFrameStart(300) - TimeSpan.FromTicks(1);
|
||||
Assert.Equal(300, FrameTime.TimeToFrame(lastTickOfFrame299, 30, 1));
|
||||
|
||||
wrapper.Update(FrameTimeOf(299));
|
||||
wrapper.Update(lastTickOfFrame299);
|
||||
|
||||
Assert.Equal(0, wrapper.ShownChunk);
|
||||
Assert.Equal(FrameTimeOf(299), chunkSources[0].LastUpdateTime);
|
||||
Assert.Equal(lastTickOfFrame299, chunkSources[0].LastUpdateTime);
|
||||
Assert.Equal(299, focus.Get(source));
|
||||
}
|
||||
|
||||
|
||||
@@ -133,12 +133,13 @@ internal static class FFmpegProcessRunner
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (inputFailure is IOException)
|
||||
throw new InvalidOperationException(string.Concat("Failed to send frames to FFmpeg. ", diagnostics.ToString()), inputFailure);
|
||||
if (inputFailure is not null)
|
||||
var result = new FFmpegProcessResult(process.ExitCode, diagnostics.ToString());
|
||||
if (inputFailure is IOException && result.IsSuccess)
|
||||
throw new InvalidOperationException(string.Concat("Failed to send frames to FFmpeg. ", result.Diagnostics), inputFailure);
|
||||
if (inputFailure is not (null or IOException))
|
||||
ExceptionDispatchInfo.Throw(inputFailure);
|
||||
|
||||
return new FFmpegProcessResult(process.ExitCode, diagnostics.ToString());
|
||||
return result;
|
||||
}
|
||||
|
||||
static async Task WriteStandardInputAsync(Process process, FFmpegInputWriter writer, CancellationToken cancellationToken)
|
||||
|
||||
@@ -10,6 +10,7 @@ public enum ProxyEncodeFailure
|
||||
FFmpegFailed,
|
||||
NoOutput,
|
||||
SourceChanged,
|
||||
GraphicsDeviceLost,
|
||||
}
|
||||
|
||||
internal sealed class ProxyEncodeException(ProxyEncodeFailure failure, string message) : Exception(message)
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using ProxyForge.Sources;
|
||||
using Vortice.DXGI;
|
||||
using YukkuriMovieMaker.Commons;
|
||||
using YukkuriMovieMaker.Plugin.FileSource;
|
||||
|
||||
@@ -35,6 +36,8 @@ internal delegate Task<IProxyEncodeSession> ProxyEncodeSessionFactory(ProxyEncod
|
||||
internal sealed class ProxyEncoder(FFmpegExecutables executables, VideoSourceFactory sourceFactory)
|
||||
{
|
||||
const int DiagnosticExcerptLength = 200;
|
||||
const int DeviceLostMaxAttempts = 3;
|
||||
static readonly TimeSpan DeviceLostRetryDelay = TimeSpan.FromSeconds(1);
|
||||
|
||||
public async Task<IProxyEncodeSession> OpenAsync(ProxyEncodeRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -47,63 +50,84 @@ internal sealed class ProxyEncoder(FFmpegExecutables executables, VideoSourceFac
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
Directory.CreateDirectory(request.WorkingDirectory);
|
||||
|
||||
GraphicsDevices? devices = null;
|
||||
IGraphicsDevicesAndContext? context = null;
|
||||
IVideoFileSource? source = null;
|
||||
ProxyFrameRenderer? renderer = null;
|
||||
|
||||
try
|
||||
for (var attempt = 1; ; attempt++)
|
||||
{
|
||||
devices = new GraphicsDevices();
|
||||
context = devices.CreateContext();
|
||||
context.DeviceContext.SetDpi(ProxyFrameRenderer.ReferenceDpi, ProxyFrameRenderer.ReferenceDpi);
|
||||
GraphicsDevices? devices = null;
|
||||
IGraphicsDevicesAndContext? context = null;
|
||||
IVideoFileSource? source = null;
|
||||
ProxyFrameRenderer? renderer = null;
|
||||
|
||||
source = sourceFactory(context, request.SourcePath)
|
||||
?? throw new ProxyEncodeException(ProxyEncodeFailure.SourceUnavailable, "No video file source plugin was able to open the input file.");
|
||||
try
|
||||
{
|
||||
devices = new GraphicsDevices();
|
||||
context = devices.CreateContext();
|
||||
context.DeviceContext.SetDpi(ProxyFrameRenderer.ReferenceDpi, ProxyFrameRenderer.ReferenceDpi);
|
||||
|
||||
var duration = source.Duration;
|
||||
if (duration <= TimeSpan.Zero)
|
||||
throw new ProxyEncodeException(ProxyEncodeFailure.NoFrames, "The video source reported a zero duration.");
|
||||
source = sourceFactory(context, request.SourcePath)
|
||||
?? throw new ProxyEncodeException(ProxyEncodeFailure.SourceUnavailable, "No video file source plugin was able to open the input file.");
|
||||
|
||||
var frameCount = source.GetFrameIndex(duration);
|
||||
if (frameCount <= 0)
|
||||
throw new ProxyEncodeException(ProxyEncodeFailure.NoFrames, "The video source reported no frames.");
|
||||
var duration = source.Duration;
|
||||
if (duration <= TimeSpan.Zero)
|
||||
throw new ProxyEncodeException(ProxyEncodeFailure.NoFrames, "The video source reported a zero duration.");
|
||||
|
||||
var frameRate = FrameRateResolver.Resolve(source.GetFrameIndex, frameCount, duration);
|
||||
var frameCount = source.GetFrameIndex(duration);
|
||||
if (frameCount <= 0)
|
||||
throw new ProxyEncodeException(ProxyEncodeFailure.NoFrames, "The video source reported no frames.");
|
||||
|
||||
source.Update(frameRate.GetSampleTime(0));
|
||||
var display = DisplayBounds.Measure(context.DeviceContext, source.Output);
|
||||
if (!display.IsUsable)
|
||||
throw new ProxyEncodeException(ProxyEncodeFailure.UnusableSize, "The video source reported an unusable image size.");
|
||||
var frameRate = FrameRateResolver.Resolve(source.GetFrameIndex, frameCount, duration);
|
||||
|
||||
var geometry = ProxyGeometryCalculator.Calculate(display.PixelWidth, display.PixelHeight, request.Scale);
|
||||
renderer = new ProxyFrameRenderer(context, source.Output, display, geometry);
|
||||
source.Update(frameRate.GetSampleTime(0));
|
||||
var display = DisplayBounds.Measure(context.DeviceContext, source.Output);
|
||||
if (!display.IsUsable)
|
||||
throw new ProxyEncodeException(ProxyEncodeFailure.UnusableSize, "The video source reported an unusable image size.");
|
||||
|
||||
var videoEncoder = await FFmpegEncoderSelector.ResolveAsync(
|
||||
executables.FFmpegPath,
|
||||
request.UsesHardwareEncoder,
|
||||
geometry.Width,
|
||||
geometry.Height,
|
||||
request.WorkingDirectory,
|
||||
cancellationToken).ConfigureAwait(false);
|
||||
var geometry = ProxyGeometryCalculator.Calculate(display.PixelWidth, display.PixelHeight, request.Scale);
|
||||
renderer = new ProxyFrameRenderer(context, source.Output, display, geometry);
|
||||
|
||||
var analysis = new ProxyAnalysis(geometry, display, frameRate, duration, frameCount);
|
||||
var session = new Session(executables, request, analysis, videoEncoder, devices, context, source, renderer);
|
||||
devices = null;
|
||||
context = null;
|
||||
source = null;
|
||||
renderer = null;
|
||||
return session;
|
||||
}
|
||||
finally
|
||||
{
|
||||
renderer?.Dispose();
|
||||
source?.Dispose();
|
||||
context?.Dispose();
|
||||
devices?.Dispose();
|
||||
var videoEncoder = await FFmpegEncoderSelector.ResolveAsync(
|
||||
executables.FFmpegPath,
|
||||
request.UsesHardwareEncoder,
|
||||
geometry.Width,
|
||||
geometry.Height,
|
||||
request.WorkingDirectory,
|
||||
cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var analysis = new ProxyAnalysis(geometry, display, frameRate, duration, frameCount);
|
||||
var session = new Session(executables, request, analysis, videoEncoder, devices, context, source, renderer);
|
||||
devices = null;
|
||||
context = null;
|
||||
source = null;
|
||||
renderer = null;
|
||||
return session;
|
||||
}
|
||||
catch (Exception exception) when (IsDeviceLost(exception))
|
||||
{
|
||||
if (attempt >= DeviceLostMaxAttempts)
|
||||
throw new ProxyEncodeException(ProxyEncodeFailure.GraphicsDeviceLost, "The GPU device was removed, hung, or reset.");
|
||||
|
||||
Log.Default.Write($"ProxyForge: GPU デバイスが失われたため再試行します。({attempt}/{DeviceLostMaxAttempts})", exception);
|
||||
}
|
||||
finally
|
||||
{
|
||||
renderer?.Dispose();
|
||||
source?.Dispose();
|
||||
context?.Dispose();
|
||||
devices?.Dispose();
|
||||
}
|
||||
|
||||
await Task.Delay(DeviceLostRetryDelay, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsDeviceLost(Exception exception)
|
||||
{
|
||||
if (exception is not (SharpGen.Runtime.SharpGenException or System.Runtime.InteropServices.COMException))
|
||||
return false;
|
||||
|
||||
SharpGen.Runtime.Result result = exception.HResult;
|
||||
return result == ResultCode.DeviceRemoved || result == ResultCode.DeviceHung || result == ResultCode.DeviceReset;
|
||||
}
|
||||
|
||||
static void TryDelete(string path)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<UseWPF>true</UseWPF>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>2.0.0</Version>
|
||||
<Version>2.0.2</Version>
|
||||
<Platforms>AnyCPU;x64;x64</Platforms>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -49,3 +49,4 @@ FailureTransparent,,透明を含むため対象外です,Excluded because it con
|
||||
FailureFFmpegFailed,,ffmpeg が失敗しました,ffmpeg failed,ffmpeg 失败,ffmpeg 失敗,ffmpeg가 실패했습니다,ffmpeg falló,فشل ffmpeg,ffmpeg gagal
|
||||
FailureNoOutput,,出力が作られませんでした,No output was produced,未生成输出,未產生輸出,출력이 만들어지지 않았습니다,No se produjo ninguna salida,لم يتم إنتاج أي مخرجات,Tidak ada keluaran yang dihasilkan
|
||||
FailureSourceChanged,,元の動画が変更されました,The source video was modified,源视频已被修改,來源影片已被修改,원본 동영상이 변경되었습니다,El vídeo de origen fue modificado,تم تعديل الفيديو المصدر,Video sumber telah diubah
|
||||
FailureGraphicsDeviceLost,,GPU デバイスが失われました,The GPU device was lost,GPU 设备已丢失,GPU 裝置已遺失,GPU 디바이스가 제거되었습니다,Se perdió el dispositivo de la GPU,تم فقدان جهاز الرسومات,Perangkat GPU telah hilang
|
||||
|
@@ -44,6 +44,7 @@ internal sealed class GenerationItemViewModel : Bindable
|
||||
ProxyEncodeFailure.FFmpegFailed => Texts.FailureFFmpegFailed,
|
||||
ProxyEncodeFailure.NoOutput => Texts.FailureNoOutput,
|
||||
ProxyEncodeFailure.SourceChanged => Texts.FailureSourceChanged,
|
||||
ProxyEncodeFailure.GraphicsDeviceLost => Texts.FailureGraphicsDeviceLost,
|
||||
_ => failure.ToString(),
|
||||
};
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using ProxyForge.Encoding;
|
||||
using ProxyForge.ViewModels;
|
||||
|
||||
@@ -31,11 +32,7 @@ internal static class GenerationProgressWindowHost
|
||||
Update();
|
||||
}
|
||||
|
||||
public static void Shutdown()
|
||||
{
|
||||
window?.CloseForShutdown();
|
||||
window = null;
|
||||
}
|
||||
public static void Shutdown() => window?.CloseForShutdown();
|
||||
|
||||
static void OnItemsChanged(object? sender, NotifyCollectionChangedEventArgs e) => Update();
|
||||
|
||||
@@ -56,16 +53,18 @@ internal static class GenerationProgressWindowHost
|
||||
}
|
||||
|
||||
window ??= Create();
|
||||
if (!window.IsVisible)
|
||||
if (window is { IsVisible: false })
|
||||
window.Show();
|
||||
}
|
||||
|
||||
static GenerationProgressWindow Create()
|
||||
static GenerationProgressWindow? Create()
|
||||
{
|
||||
var created = new GenerationProgressWindow(new GenerationProgressViewModel(items!, cancelAll!));
|
||||
if (Application.Current?.MainWindow is { IsLoaded: true } owner)
|
||||
created.Owner = owner;
|
||||
if (Application.Current?.MainWindow is not { } owner || new WindowInteropHelper(owner).Handle == 0)
|
||||
return null;
|
||||
|
||||
var created = new GenerationProgressWindow(new GenerationProgressViewModel(items!, cancelAll!)) { Owner = owner };
|
||||
created.HideRequested += (_, _) => suppressed = true;
|
||||
created.Closed += (_, _) => window = null;
|
||||
return created;
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする