コミットを比較
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
85451eb49a
|
||
|
|
e2e8caf836
|
||
|
|
e6f3bc6557
|
||
|
|
ad1d6cdd50
|
検索条件に一致するファイルはありません
@@ -1,5 +1,5 @@
|
||||
========================================
|
||||
ProxyForge for YMM4 v2.0.1
|
||||
ProxyForge for YMM4 v2.0.2
|
||||
========================================
|
||||
YukkuriMovieMaker4(YMM4)上で動作する、編集の間だけ使う解像度の低い
|
||||
動画ファイルを作り、プレビューでは元の動画の代わりにそれを読み込む
|
||||
|
||||
@@ -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.1</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(),
|
||||
};
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする