diff --git a/Spine/Exporters/FFmpegVideoExporter.cs b/Spine/Exporters/FFmpegVideoExporter.cs index b73492d..b52d0ab 100644 --- a/Spine/Exporters/FFmpegVideoExporter.cs +++ b/Spine/Exporters/FFmpegVideoExporter.cs @@ -35,6 +35,33 @@ namespace Spine.Exporters Mov, } + /// + /// Apng 格式预测器算法 + /// + public enum ApngPredMethod + { + None = 0, + Sub = 1, + Up = 2, + Avg = 3, + Paeth = 4, + Mixed = 5, + } + + /// + /// Mov prores_ks 编码器 profile 参数 + /// + public enum MovProfile + { + Auto = -1, + Proxy = 0, + Light = 1, + Standard = 2, + High = 3, + Yuv4444 = 4, + Yuv4444Extreme = 5, + } + /// /// 视频格式 /// @@ -60,10 +87,10 @@ namespace Spine.Exporters private bool _lossless = false; /// - /// [Apng] 预测器算法, 取值范围 0-5, 分别对应 none, sub, up, avg, paeth, mixed + /// [Apng] 预测器算法 /// - public int PredMethod { get => _predMethod; set => _predMethod = Math.Clamp(value, 0, 5); } - private int _predMethod = 5; + public ApngPredMethod PredMethod { get => _predMethod; set => _predMethod = value; } + private ApngPredMethod _predMethod = ApngPredMethod.Mixed; /// /// [Mp4/Webm/Mkv] CRF @@ -72,10 +99,10 @@ namespace Spine.Exporters private int _crf = 23; /// - /// [Mov] prores_ks 编码器的配置等级, -1 是自动, 越高质量越好, 只有 4 及以上才有透明通道 + /// [Mov] prores_ks 编码器的配置等级, 越高质量越好, 只有 及以上才有透明通道 /// - public int Profile { get => _profile; set => _profile = Math.Clamp(value, -1, 5); } - private int _profile = 5; + public MovProfile Profile { get => _profile; set => _profile = value; } + private MovProfile _profile = MovProfile.Yuv4444Extreme; /// /// 获取的一帧, 结果是预乘的 @@ -142,7 +169,7 @@ namespace Spine.Exporters private void SetApngOptions(FFMpegArgumentOptions options) { - var customArgs = $"-vf unpremultiply=inplace=1 -plays {(_loop ? 0 : 1)} -pred {_predMethod}"; + var customArgs = $"-vf unpremultiply=inplace=1 -plays {(_loop ? 0 : 1)} -pred {(int)_predMethod}"; options.ForceFormat("apng").WithVideoCodec("apng").ForcePixelFormat("rgba") .WithCustomArgument(customArgs); } @@ -179,7 +206,7 @@ namespace Spine.Exporters var customArgs = "-vf unpremultiply=inplace=1"; options.ForceFormat("mov").WithVideoCodec("prores_ks").ForcePixelFormat("yuva444p10le") .WithFastStart() - .WithCustomArgument($"-profile {_profile}") + .WithCustomArgument($"-profile {(int)_profile}") .WithCustomArgument(customArgs); } } diff --git a/SpineViewer/Resources/Strings/en.xaml b/SpineViewer/Resources/Strings/en.xaml index e53a826..e4bdbfd 100644 --- a/SpineViewer/Resources/Strings/en.xaml +++ b/SpineViewer/Resources/Strings/en.xaml @@ -211,7 +211,7 @@ CRF Parameter [Mp4/Webm/Mkv] CRF parameter, range 0-63, lower value means higher quality Profile Parameter - [Mov] Profile parameter, integer between -1 and 5, -1 means automatic, higher values indicate higher quality, Alpha channel encoding is only available when value is 4 or higher + [Mov] Profile parameter, an integer between -1 and 5, corresponding to: auto, proxy, lt, standard, hq, 4444, and 4444xq. Alpha channel encoding is available only when the value is 4 or higher. Export Format FFmpeg export format (equivalent to "-f"), e.g. "mp4", "webm" diff --git a/SpineViewer/Resources/Strings/ja.xaml b/SpineViewer/Resources/Strings/ja.xaml index fcecb2c..16559c7 100644 --- a/SpineViewer/Resources/Strings/ja.xaml +++ b/SpineViewer/Resources/Strings/ja.xaml @@ -211,7 +211,7 @@ CRF パラメータ [Mp4/Webm/Mkv] CRF パラメータ、範囲0-63。値が小さいほど品質が高い プロファイルパラメータ - [Mov] プロファイルパラメータ、-1から5の整数、 -1は自動、値が大きいほど品質が高い、 値が4以上の場合のみアルファチャンネルをエンコード可能 + [Mov] Profile パラメータ。値は -1 ~ 5 の整数で、 それぞれ auto、proxy、lt、standard、hq、4444、4444xq に対応します。 値が 4 以上の場合のみアルファチャンネルのエンコードが可能です。 エクスポートフォーマット FFmpegエクスポートフォーマット。パラメーター“-f”に相当します。例: “mp4”、“webm” diff --git a/SpineViewer/Resources/Strings/zh.xaml b/SpineViewer/Resources/Strings/zh.xaml index a621d3f..9fc695c 100644 --- a/SpineViewer/Resources/Strings/zh.xaml +++ b/SpineViewer/Resources/Strings/zh.xaml @@ -211,7 +211,7 @@ CRF 参数 [Mp4/Webm/Mkv] CRF 参数,取值范围 0-63,越小质量越高 Profile 参数 - [Mov] Profile 参数,取值集合为 -1 到 5 之间的整数, -1 表示自动,0-5 取值越高质量越高, 仅在取值大于等于 4 时可以编码透明度通道 + [Mov] Profile 参数,取值范围为 -1 到 5 之间的整数, 分别对应 auto、proxy、lt、standard、hq、4444、4444xq 几种配置, 仅在取值大于等于 4 时可以编码透明度通道 导出格式 FFmpeg 导出格式,等价于参数 “-f”,例如 “mp4”、“webm” diff --git a/SpineViewer/ViewModels/Exporters/FFmpegVideoExporterViewModel.cs b/SpineViewer/ViewModels/Exporters/FFmpegVideoExporterViewModel.cs index f0faa54..446639e 100644 --- a/SpineViewer/ViewModels/Exporters/FFmpegVideoExporterViewModel.cs +++ b/SpineViewer/ViewModels/Exporters/FFmpegVideoExporterViewModel.cs @@ -19,6 +19,8 @@ namespace SpineViewer.ViewModels.Exporters public class FFmpegVideoExporterViewModel(MainWindowViewModel vmMain) : VideoExporterViewModel(vmMain) { public static ImmutableArray VideoFormatOptions { get; } = Enum.GetValues().ToImmutableArray(); + public static ImmutableArray ApngPredMethodOptions { get; } = Enum.GetValues().ToImmutableArray(); + public static ImmutableArray MovProfileOptions { get; } = Enum.GetValues().ToImmutableArray(); public FFmpegVideoExporter.VideoFormat Format { @@ -57,8 +59,8 @@ namespace SpineViewer.ViewModels.Exporters public bool EnableParamLossless => _format == FFmpegVideoExporter.VideoFormat.Webp; - public int PredMethod { get => _predMethod; set => SetProperty(ref _predMethod, Math.Clamp(value, 0, 5)); } - protected int _predMethod = 5; + public FFmpegVideoExporter.ApngPredMethod PredMethod { get => _predMethod; set => SetProperty(ref _predMethod, value); } + protected FFmpegVideoExporter.ApngPredMethod _predMethod = FFmpegVideoExporter.ApngPredMethod.Mixed; public bool EnableParamApngPred => _format == FFmpegVideoExporter.VideoFormat.Apng; @@ -71,8 +73,8 @@ namespace SpineViewer.ViewModels.Exporters _format == FFmpegVideoExporter.VideoFormat.Webm || _format == FFmpegVideoExporter.VideoFormat.Mkv; - public int Profile { get => _profile; set => SetProperty(ref _profile, Math.Clamp(value, -1, 5)); } - protected int _profile = 5; + public FFmpegVideoExporter.MovProfile Profile { get => _profile; set => SetProperty(ref _profile, value); } + protected FFmpegVideoExporter.MovProfile _profile = FFmpegVideoExporter.MovProfile.Yuv4444Extreme; public bool EnableParamProfile => _format == FFmpegVideoExporter.VideoFormat.Mov; diff --git a/SpineViewer/Views/ExporterDialogs/FFmpegVideoExporterDialog.xaml b/SpineViewer/Views/ExporterDialogs/FFmpegVideoExporterDialog.xaml index fbfaae2..91e3efa 100644 --- a/SpineViewer/Views/ExporterDialogs/FFmpegVideoExporterDialog.xaml +++ b/SpineViewer/Views/ExporterDialogs/FFmpegVideoExporterDialog.xaml @@ -248,7 +248,10 @@