From bb42ce6ba18aeb9b98b10cf616676642f92ac910 Mon Sep 17 00:00:00 2001 From: routersys Date: Sun, 13 Sep 2026 10:26:24 +0900 Subject: [PATCH] =?UTF-8?q?YMM4=E5=90=8C=E6=A2=B1=E3=81=AEffmpeg=E3=81=AE?= =?UTF-8?q?=E5=A0=B4=E6=89=80=E3=81=AE=E8=A7=A3=E6=B1=BA=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProxyForge/Encoding/FFmpegRuntime.cs | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 ProxyForge/Encoding/FFmpegRuntime.cs diff --git a/ProxyForge/Encoding/FFmpegRuntime.cs b/ProxyForge/Encoding/FFmpegRuntime.cs new file mode 100644 index 0000000..035c3b5 --- /dev/null +++ b/ProxyForge/Encoding/FFmpegRuntime.cs @@ -0,0 +1,45 @@ +using System.IO; +using System.Runtime.CompilerServices; +using YukkuriMovieMaker.Commons; +using YukkuriMovieMaker.Plugin.FileSource.FFmpeg; + +namespace ProxyForge.Encoding; + +internal readonly record struct FFmpegExecutables(string FFmpegPath) +{ + public static FFmpegExecutables Unavailable => new(string.Empty); + + public bool IsAvailable => FFmpegPath.Length != 0; +} + +internal static class FFmpegRuntime +{ + static readonly Lazy Resolved = new(Resolve, LazyThreadSafetyMode.ExecutionAndPublication); + + public static FFmpegExecutables Executables => Resolved.Value; + + static FFmpegExecutables Resolve() + { + string path; + try + { + path = GetFFmpegExePath(); + } + catch (Exception exception) when (exception is TypeLoadException or MissingMemberException or FileNotFoundException) + { + Log.Default.Write("ProxyForge: YMM4 の ffmpeg の場所を取得できませんでした。", exception); + return FFmpegExecutables.Unavailable; + } + + if (!File.Exists(path)) + { + Log.Default.Write($"ProxyForge: ffmpeg.exe が見つかりません。{path}"); + return FFmpegExecutables.Unavailable; + } + + return new FFmpegExecutables(path); + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static string GetFFmpegExePath() => FFmpegResourceLocator.GetFFmpegExePath(); +}