4 コミット
作成者 SHA1 メッセージ 日付
routersys 85451eb49a バージョンをv2.0.2へ上げる
リリース / build-and-release (workflow_dispatch) Actions がタグ v2.0.2 のコミットから作成しました
2026-09-21 12:54:34 +09:00
routersys e2e8caf836 デバイス消失の検知をCOM例外にも広げる 2026-09-21 12:10:02 +09:00
routersys e6f3bc6557 GPUデバイス消失時に再作成して再試行する 2026-09-21 12:04:39 +09:00
routersys ad1d6cdd50 GPUデバイスロストを固有の失敗として扱う 2026-09-21 10:33:33 +09:00
6個のファイルの変更、74行の追加、47行の削除

検索条件に一致するファイルはありません

+1 -1
ファイルの表示
@@ -1,5 +1,5 @@
========================================
ProxyForge for YMM4 v2.0.1
ProxyForge for YMM4 v2.0.2
========================================
YukkuriMovieMaker4(YMM4)上で動作する、編集の間だけ使う解像度の低い
動画ファイルを作り、プレビューでは元の動画の代わりにそれを読み込む
+1
ファイルの表示
@@ -10,6 +10,7 @@ public enum ProxyEncodeFailure
FFmpegFailed,
NoOutput,
SourceChanged,
GraphicsDeviceLost,
}
internal sealed class ProxyEncodeException(ProxyEncodeFailure failure, string message) : Exception(message)
+69 -45
ファイルの表示
@@ -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
+1 -1
ファイルの表示
@@ -5,7 +5,7 @@
<UseWPF>true</UseWPF>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>2.0.1</Version>
<Version>2.0.2</Version>
<Platforms>AnyCPU;x64;x64</Platforms>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
+1
ファイルの表示
@@ -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
1 Key Parameter ja-jp en-us zh-cn zh-tw ko-kr es-es ar-sa id-id
49 FailureFFmpegFailed ffmpeg が失敗しました ffmpeg failed ffmpeg 失败 ffmpeg 失敗 ffmpeg가 실패했습니다 ffmpeg falló فشل ffmpeg ffmpeg gagal
50 FailureNoOutput 出力が作られませんでした No output was produced 未生成输出 未產生輸出 출력이 만들어지지 않았습니다 No se produjo ninguna salida لم يتم إنتاج أي مخرجات Tidak ada keluaran yang dihasilkan
51 FailureSourceChanged 元の動画が変更されました The source video was modified 源视频已被修改 來源影片已被修改 원본 동영상이 변경되었습니다 El vídeo de origen fue modificado تم تعديل الفيديو المصدر Video sumber telah diubah
52 FailureGraphicsDeviceLost GPU デバイスが失われました The GPU device was lost GPU 设备已丢失 GPU 裝置已遺失 GPU 디바이스가 제거되었습니다 Se perdió el dispositivo de la GPU تم فقدان جهاز الرسومات Perangkat GPU telah hilang
+1
ファイルの表示
@@ -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(),
};