use new form layout for ffmpeg profile editor (#2113)
This commit is contained in:
@@ -75,6 +75,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Update form layout to be less cramped and to work better on mobile
|
||||
- All new (split) settings pages
|
||||
- Channel editor
|
||||
- FFmpeg Profile editor
|
||||
|
||||
### Fixed
|
||||
- Fix QSV acceleration in docker with older Intel devices
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<MudForm Model="@_model" @ref="@_form" Validation="@(_validator.ValidateValue)" ValidationDelay="0" Style="max-height: 100%">
|
||||
<MudPaper Square="true" Style="display: flex; height: 64px; min-height: 64px; width: 100%; z-index: 100; align-items: center">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Class="ml-8" OnClick="HandleSubmitAsync" StartIcon="@(IsEdit ? Icons.Material.Filled.Save : Icons.Material.Filled.Add)">@(IsEdit ? "Save Changes" : "Add Channel")</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Class="ml-8" OnClick="HandleSubmitAsync" StartIcon="@(IsEdit ? Icons.Material.Filled.Save : Icons.Material.Filled.Add)">@(IsEdit ? "Save Channel" : "Add Channel")</MudButton>
|
||||
</MudPaper>
|
||||
<div class="d-flex flex-column" style="height: 100vh; overflow-x: auto">
|
||||
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="pt-8">
|
||||
|
||||
+254
-201
@@ -7,6 +7,8 @@
|
||||
@using ErsatzTV.FFmpeg
|
||||
@using ErsatzTV.FFmpeg.Format
|
||||
@using ErsatzTV.FFmpeg.Preset
|
||||
@using ErsatzTV.Validators
|
||||
@using FluentValidation.Results
|
||||
@using Microsoft.Extensions.Caching.Memory
|
||||
@implements IDisposable
|
||||
@inject NavigationManager NavigationManager
|
||||
@@ -16,202 +18,255 @@
|
||||
@inject IMemoryCache MemoryCache
|
||||
@inject PersistentComponentState ApplicationState
|
||||
|
||||
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="pt-8">
|
||||
@if (_editContext is not null)
|
||||
{
|
||||
<EditForm EditContext="_editContext" OnSubmit="@HandleSubmitAsync">
|
||||
<FluentValidationValidator/>
|
||||
<MudCard>
|
||||
<MudCardHeader>
|
||||
<CardHeaderContent>
|
||||
<MudText Typo="Typo.h5">@(IsEdit ? "Edit FFmpeg Profile" : "Add FFmpeg Profile")</MudText>
|
||||
</CardHeaderContent>
|
||||
</MudCardHeader>
|
||||
<MudCardContent>
|
||||
<MudGrid>
|
||||
<MudItem xs="12">
|
||||
<MudGrid Spacing="8" Justify="Justify.Center">
|
||||
<MudItem>
|
||||
<MudText Typo="Typo.h6">General</MudText>
|
||||
<MudTextField Label="Name" @bind-Value="_model.Name" For="@(() => _model.Name)"/>
|
||||
<MudElement HtmlTag="div" Class="mt-3">
|
||||
<MudTextField Label="Thread Count" @bind-Value="@_model.ThreadCount" For="@(() => _model.ThreadCount)"/>
|
||||
</MudElement>
|
||||
<MudElement HtmlTag="div" Class="mt-3">
|
||||
<MudSelect Label="Preferred Resolution" @bind-Value="_model.Resolution" For="@(() => _model.Resolution)">
|
||||
@foreach (ResolutionViewModel resolution in _resolutions)
|
||||
{
|
||||
<MudSelectItem Value="@resolution">@resolution.Name</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudElement>
|
||||
<MudElement HtmlTag="div" Class="mt-3">
|
||||
<MudSelect Label="Scaling Behavior" @bind-Value="_model.ScalingBehavior" For="@(() => _model.ScalingBehavior)">
|
||||
<MudSelectItem Value="@ScalingBehavior.ScaleAndPad">Scale and Pad</MudSelectItem>
|
||||
<MudSelectItem Value="@ScalingBehavior.Stretch">Stretch</MudSelectItem>
|
||||
<MudSelectItem Value="@ScalingBehavior.Crop">Crop</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudElement>
|
||||
</MudItem>
|
||||
<MudItem>
|
||||
<MudText Typo="Typo.h6">Video</MudText>
|
||||
<MudSelect Label="Format" @bind-Value="_model.VideoFormat" For="@(() => _model.VideoFormat)">
|
||||
<MudSelectItem Value="@FFmpegProfileVideoFormat.H264">h264</MudSelectItem>
|
||||
<MudSelectItem Value="@FFmpegProfileVideoFormat.Hevc">hevc</MudSelectItem>
|
||||
<MudSelectItem Value="@FFmpegProfileVideoFormat.Mpeg2Video">mpeg-2</MudSelectItem>
|
||||
</MudSelect>
|
||||
<MudSelect Label="Profile"
|
||||
@bind-Value="_model.VideoProfile"
|
||||
For="@(() => _model.VideoProfile)"
|
||||
Disabled="@(_model.VideoFormat != FFmpegProfileVideoFormat.H264 || _model.HardwareAcceleration != HardwareAccelerationKind.Nvenc && _model.HardwareAcceleration != HardwareAccelerationKind.Qsv && _model.HardwareAcceleration != HardwareAccelerationKind.None)"
|
||||
Clearable="true">
|
||||
<MudSelectItem Value="@VideoProfile.Main">main</MudSelectItem>
|
||||
<MudSelectItem Value="@VideoProfile.High">high</MudSelectItem>
|
||||
</MudSelect>
|
||||
@{
|
||||
ICollection<string> presets = AvailablePresets.ForAccelAndFormat(MapAccel(_model.HardwareAcceleration), MapVideoFormat(_model.VideoFormat));
|
||||
}
|
||||
<MudSelect Label="Preset"
|
||||
@bind-Value="_model.VideoPreset"
|
||||
For="@(() => _model.VideoPreset)"
|
||||
Disabled="@(presets.Count == 0)"
|
||||
Clearable="true">
|
||||
@foreach (string preset in presets)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(preset))
|
||||
{
|
||||
<MudSelectItem Value="@preset">@preset</MudSelectItem>
|
||||
}
|
||||
}
|
||||
</MudSelect>
|
||||
<MudElement HtmlTag="div" Class="mt-3">
|
||||
<MudCheckBox Label="Allow B-Frames" @bind-Value="@_model.AllowBFrames" For="@(() => _model.AllowBFrames)"/>
|
||||
</MudElement>
|
||||
<MudSelect Label="Bit Depth" @bind-Value="_model.BitDepth" For="@(() => _model.BitDepth)">
|
||||
<MudSelectItem Value="@FFmpegProfileBitDepth.EightBit">8-bit</MudSelectItem>
|
||||
<MudSelectItem Value="@FFmpegProfileBitDepth.TenBit">10-bit</MudSelectItem>
|
||||
</MudSelect>
|
||||
<MudElement HtmlTag="div" Class="mt-3">
|
||||
<MudTextField Label="Bitrate" @bind-Value="_model.VideoBitrate" For="@(() => _model.VideoBitrate)" Adornment="Adornment.End" AdornmentText="kBit/s"/>
|
||||
</MudElement>
|
||||
<MudElement HtmlTag="div" Class="mt-3">
|
||||
<MudTextField Label="Buffer Size" @bind-Value="_model.VideoBufferSize" For="@(() => _model.VideoBufferSize)" Adornment="Adornment.End" AdornmentText="kBit"/>
|
||||
</MudElement>
|
||||
<MudElement HtmlTag="div" Class="mt-3">
|
||||
<MudSelect Label="Hardware Acceleration" @bind-Value="_model.HardwareAcceleration" For="@(() => _model.HardwareAcceleration)">
|
||||
@foreach (HardwareAccelerationKind hwAccel in _hardwareAccelerationKinds)
|
||||
{
|
||||
<MudSelectItem Value="@hwAccel">@hwAccel</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudElement>
|
||||
@if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
@if (_model.HardwareAcceleration == HardwareAccelerationKind.Vaapi)
|
||||
{
|
||||
<MudElement HtmlTag="div" Class="mt-3">
|
||||
<MudSelect Disabled="@(_model.HardwareAcceleration != HardwareAccelerationKind.Vaapi)" Label="VAAPI Driver" @bind-Value="_model.VaapiDriver" For="@(() => _model.VaapiDriver)">
|
||||
@foreach (VaapiDriver driver in Enum.GetValues<VaapiDriver>())
|
||||
{
|
||||
<MudSelectItem Value="@driver">@driver</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudElement>
|
||||
}
|
||||
<MudForm Model="@_model" @ref="@_form" Validation="@(_validator.ValidateValue)" ValidationDelay="0" Style="max-height: 100%">
|
||||
<MudPaper Square="true" Style="display: flex; height: 64px; min-height: 64px; width: 100%; z-index: 100; align-items: center">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Class="ml-8" OnClick="HandleSubmitAsync" StartIcon="@(IsEdit ? Icons.Material.Filled.Save : Icons.Material.Filled.Add)">@(IsEdit ? "Save Profile" : "Add Profile")</MudButton>
|
||||
</MudPaper>
|
||||
<div class="d-flex flex-column" style="height: 100vh; overflow-x: auto">
|
||||
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="pt-8">
|
||||
<MudText Typo="Typo.h5" Class="mb-2">General</MudText>
|
||||
<MudDivider Class="mb-6"/>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Name</MudText>
|
||||
</div>
|
||||
<MudTextField @bind-Value="_model.Name" For="@(() => _model.Name)" Immediate="true"/>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Thread Count</MudText>
|
||||
</div>
|
||||
<MudTextField @bind-Value="@_model.ThreadCount" For="@(() => _model.ThreadCount)" />
|
||||
</MudStack>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Preferred Resolution</MudText>
|
||||
</div>
|
||||
<MudSelect @bind-Value="_model.Resolution" For="@(() => _model.Resolution)">
|
||||
@foreach (ResolutionViewModel resolution in _resolutions)
|
||||
{
|
||||
<MudSelectItem Value="@resolution">@resolution.Name</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Scaling Behavior</MudText>
|
||||
</div>
|
||||
<MudSelect @bind-Value="_model.ScalingBehavior" For="@(() => _model.ScalingBehavior)">
|
||||
<MudSelectItem Value="@ScalingBehavior.ScaleAndPad">Scale and Pad</MudSelectItem>
|
||||
<MudSelectItem Value="@ScalingBehavior.Stretch">Stretch</MudSelectItem>
|
||||
<MudSelectItem Value="@ScalingBehavior.Crop">Crop</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudStack>
|
||||
<MudText Typo="Typo.h5" Class="mb-2">Video</MudText>
|
||||
<MudDivider Class="mb-6"/>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Format</MudText>
|
||||
</div>
|
||||
<MudSelect @bind-Value="_model.VideoFormat" For="@(() => _model.VideoFormat)">
|
||||
<MudSelectItem Value="@FFmpegProfileVideoFormat.H264">h264</MudSelectItem>
|
||||
<MudSelectItem Value="@FFmpegProfileVideoFormat.Hevc">hevc</MudSelectItem>
|
||||
<MudSelectItem Value="@FFmpegProfileVideoFormat.Mpeg2Video">mpeg-2</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Profile</MudText>
|
||||
</div>
|
||||
<MudSelect @bind-Value="_model.VideoProfile"
|
||||
For="@(() => _model.VideoProfile)"
|
||||
Disabled="@(_model.VideoFormat != FFmpegProfileVideoFormat.H264 || _model.HardwareAcceleration != HardwareAccelerationKind.Nvenc && _model.HardwareAcceleration != HardwareAccelerationKind.Qsv && _model.HardwareAcceleration != HardwareAccelerationKind.None)"
|
||||
Clearable="true">
|
||||
<MudSelectItem Value="@VideoProfile.Main">main</MudSelectItem>
|
||||
<MudSelectItem Value="@VideoProfile.High">high</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Preset</MudText>
|
||||
</div>
|
||||
@{
|
||||
ICollection<string> presets = AvailablePresets.ForAccelAndFormat(MapAccel(_model.HardwareAcceleration), MapVideoFormat(_model.VideoFormat));
|
||||
}
|
||||
<MudSelect @bind-Value="_model.VideoPreset"
|
||||
For="@(() => _model.VideoPreset)"
|
||||
Disabled="@(presets.Count == 0)"
|
||||
Clearable="true">
|
||||
@foreach (string preset in presets)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(preset))
|
||||
{
|
||||
<MudSelectItem Value="@preset">@preset</MudSelectItem>
|
||||
}
|
||||
}
|
||||
</MudSelect>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Allow B-Frames</MudText>
|
||||
</div>
|
||||
<MudCheckBox @bind-Value="@_model.AllowBFrames" For="@(() => _model.AllowBFrames)" Dense="true" />
|
||||
</MudStack>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Bit Depth</MudText>
|
||||
</div>
|
||||
<MudSelect @bind-Value="_model.BitDepth" For="@(() => _model.BitDepth)">
|
||||
<MudSelectItem Value="@FFmpegProfileBitDepth.EightBit">8-bit</MudSelectItem>
|
||||
<MudSelectItem Value="@FFmpegProfileBitDepth.TenBit">10-bit</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Bitrate</MudText>
|
||||
</div>
|
||||
<MudTextField @bind-Value="_model.VideoBitrate" For="@(() => _model.VideoBitrate)" Adornment="Adornment.End" AdornmentText="kBit/s"/>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Buffer Size</MudText>
|
||||
</div>
|
||||
<MudTextField @bind-Value="_model.VideoBufferSize" For="@(() => _model.VideoBufferSize)" Adornment="Adornment.End" AdornmentText="kBit"/>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Hardware Acceleration</MudText>
|
||||
</div>
|
||||
<MudSelect @bind-Value="_model.HardwareAcceleration" For="@(() => _model.HardwareAcceleration)">
|
||||
@foreach (HardwareAccelerationKind hwAccel in _hardwareAccelerationKinds)
|
||||
{
|
||||
<MudSelectItem Value="@hwAccel">@hwAccel</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudStack>
|
||||
@if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
@if (_model.HardwareAcceleration is HardwareAccelerationKind.Vaapi)
|
||||
{
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>VAAPI Driver</MudText>
|
||||
</div>
|
||||
<MudSelect @bind-Value="_model.VaapiDriver" For="@(() => _model.VaapiDriver)">
|
||||
@foreach (VaapiDriver driver in Enum.GetValues<VaapiDriver>())
|
||||
{
|
||||
<MudSelectItem Value="@driver">@driver</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>VAAPI Display</MudText>
|
||||
</div>
|
||||
<MudSelect @bind-Value="_model.VaapiDisplay" For="@(() => _model.VaapiDisplay)">
|
||||
@foreach (string display in _vaapiDisplays)
|
||||
{
|
||||
<MudSelectItem Value="@display">@display</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudStack>
|
||||
}
|
||||
|
||||
@if (_model.HardwareAcceleration == HardwareAccelerationKind.Vaapi)
|
||||
{
|
||||
<MudElement HtmlTag="div" Class="mt-3">
|
||||
<MudSelect Disabled="@(_model.HardwareAcceleration != HardwareAccelerationKind.Vaapi)"
|
||||
Label="VAAPI Display"
|
||||
@bind-Value="_model.VaapiDisplay" For="@(() => _model.VaapiDisplay)">
|
||||
@foreach (string display in _vaapiDisplays)
|
||||
{
|
||||
<MudSelectItem Value="@display">@display</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudElement>
|
||||
}
|
||||
@if (_model.HardwareAcceleration is HardwareAccelerationKind.Vaapi or HardwareAccelerationKind.Qsv)
|
||||
{
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>@(_model.HardwareAcceleration == HardwareAccelerationKind.Vaapi ? "VAAPI Device" : "QSV Device")</MudText>
|
||||
</div>
|
||||
<MudSelect @bind-Value="_model.VaapiDevice" For="@(() => _model.VaapiDevice)">
|
||||
@foreach (string device in _vaapiDevices)
|
||||
{
|
||||
<MudSelectItem Value="@device">@device</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudStack>
|
||||
}
|
||||
}
|
||||
|
||||
@if (_model.HardwareAcceleration is HardwareAccelerationKind.Vaapi or HardwareAccelerationKind.Qsv)
|
||||
{
|
||||
<MudElement HtmlTag="div" Class="mt-3">
|
||||
<MudSelect Disabled="@(_model.HardwareAcceleration != HardwareAccelerationKind.Vaapi && _model.HardwareAcceleration != HardwareAccelerationKind.Qsv)"
|
||||
Label="@(_model.HardwareAcceleration == HardwareAccelerationKind.Vaapi ? "VAAPI Device" : "QSV Device")"
|
||||
@bind-Value="_model.VaapiDevice"
|
||||
For="@(() => _model.VaapiDevice)">
|
||||
@foreach (string device in _vaapiDevices)
|
||||
{
|
||||
<MudSelectItem Value="@device">@device</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudElement>
|
||||
}
|
||||
}
|
||||
@if (_model.HardwareAcceleration == HardwareAccelerationKind.Qsv)
|
||||
{
|
||||
<MudElement HtmlTag="div" Class="mt-3">
|
||||
<MudTextField Disabled="@(_model.HardwareAcceleration != HardwareAccelerationKind.Qsv)" Label="QSV Extra Hardware Frames" @bind-Value="_model.QsvExtraHardwareFrames" For="@(() => _model.QsvExtraHardwareFrames)"/>
|
||||
</MudElement>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudElement HtmlTag="div" Class="mt-3">
|
||||
<MudSelect Label="Tonemap Algorithm"
|
||||
@bind-Value="_model.TonemapAlgorithm"
|
||||
For="@(() => _model.TonemapAlgorithm)">
|
||||
@foreach (FFmpegProfileTonemapAlgorithm algorithm in Enum.GetValues<FFmpegProfileTonemapAlgorithm>())
|
||||
{
|
||||
<MudSelectItem Value="@algorithm">@algorithm</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudElement>
|
||||
}
|
||||
<MudElement HtmlTag="div" Class="mt-3">
|
||||
<MudCheckBox Label="Normalize Frame Rate" @bind-Value="@_model.NormalizeFramerate" For="@(() => _model.NormalizeFramerate)"/>
|
||||
</MudElement>
|
||||
<MudElement HtmlTag="div" Class="mt-3">
|
||||
<MudCheckBox Label="Auto Deinterlace Video" @bind-Value="@_model.DeinterlaceVideo" For="@(() => _model.DeinterlaceVideo)"/>
|
||||
</MudElement>
|
||||
</MudItem>
|
||||
<MudItem>
|
||||
<MudText Typo="Typo.h6">Audio</MudText>
|
||||
<MudSelect Label="Format" @bind-Value="_model.AudioFormat" For="@(() => _model.AudioFormat)">
|
||||
<MudSelectItem Value="@FFmpegProfileAudioFormat.Aac">aac</MudSelectItem>
|
||||
<MudSelectItem Value="@FFmpegProfileAudioFormat.Ac3">ac3</MudSelectItem>
|
||||
</MudSelect>
|
||||
<MudElement HtmlTag="div" Class="mt-3">
|
||||
<MudTextField Label="Bitrate" @bind-Value="_model.AudioBitrate" For="@(() => _model.AudioBitrate)" Adornment="Adornment.End" AdornmentText="kBit/s"/>
|
||||
</MudElement>
|
||||
<MudElement HtmlTag="div" Class="mt-3">
|
||||
<MudTextField Label="Buffer Size" @bind-Value="_model.AudioBufferSize" For="@(() => _model.AudioBufferSize)" Adornment="Adornment.End" AdornmentText="kBit"/>
|
||||
</MudElement>
|
||||
<MudElement HtmlTag="div" Class="mt-3">
|
||||
<MudTextField Label="Channels" @bind-Value="_model.AudioChannels" For="@(() => _model.AudioChannels)"/>
|
||||
</MudElement>
|
||||
<MudElement HtmlTag="div" Class="mt-3">
|
||||
<MudTextField Label="Sample Rate" @bind-Value="_model.AudioSampleRate" For="@(() => _model.AudioSampleRate)" Adornment="Adornment.End" AdornmentText="kHz"/>
|
||||
</MudElement>
|
||||
<MudElement HtmlTag="div" Class="mt-3">
|
||||
<MudSelect Label="Normalize Loudness" @bind-Value="_model.NormalizeLoudnessMode" For="@(() => _model.NormalizeLoudnessMode)">
|
||||
<MudSelectItem Value="@NormalizeLoudnessMode.Off">Off</MudSelectItem>
|
||||
<MudSelectItem Value="@NormalizeLoudnessMode.LoudNorm">loudnorm</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudElement>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</MudCardContent>
|
||||
<MudCardActions>
|
||||
<MudButton ButtonType="ButtonType.Submit" Variant="Variant.Filled" Color="Color.Primary">
|
||||
@(IsEdit ? "Save Changes" : "Add Profile")
|
||||
</MudButton>
|
||||
</MudCardActions>
|
||||
</MudCard>
|
||||
</EditForm>
|
||||
}
|
||||
</MudContainer>
|
||||
@if (_model.HardwareAcceleration == HardwareAccelerationKind.Qsv)
|
||||
{
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>QSV Extra Hardware Frames</MudText>
|
||||
</div>
|
||||
<MudTextField @bind-Value="_model.QsvExtraHardwareFrames" For="@(() => _model.QsvExtraHardwareFrames)"/>
|
||||
</MudStack>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Tonemap Algorithm</MudText>
|
||||
</div>
|
||||
<MudSelect @bind-Value="_model.TonemapAlgorithm" For="@(() => _model.TonemapAlgorithm)">
|
||||
@foreach (FFmpegProfileTonemapAlgorithm algorithm in Enum.GetValues<FFmpegProfileTonemapAlgorithm>())
|
||||
{
|
||||
<MudSelectItem Value="@algorithm">@algorithm</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudStack>
|
||||
}
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Normalize Frame Rate</MudText>
|
||||
</div>
|
||||
<MudCheckBox @bind-Value="@_model.NormalizeFramerate" For="@(() => _model.NormalizeFramerate)" Dense="true" />
|
||||
</MudStack>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Auto Deinterlace Video</MudText>
|
||||
</div>
|
||||
<MudCheckBox @bind-Value="@_model.DeinterlaceVideo" For="@(() => _model.DeinterlaceVideo)" Dense="true" />
|
||||
</MudStack>
|
||||
<MudText Typo="Typo.h5" Class="mb-2">Audio</MudText>
|
||||
<MudDivider Class="mb-6"/>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Format</MudText>
|
||||
</div>
|
||||
<MudSelect @bind-Value="_model.AudioFormat" For="@(() => _model.AudioFormat)">
|
||||
<MudSelectItem Value="@FFmpegProfileAudioFormat.Aac">aac</MudSelectItem>
|
||||
<MudSelectItem Value="@FFmpegProfileAudioFormat.Ac3">ac3</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Bitrate</MudText>
|
||||
</div>
|
||||
<MudTextField @bind-Value="_model.AudioBitrate" For="@(() => _model.AudioBitrate)" Adornment="Adornment.End" AdornmentText="kBit/s"/>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Buffer Size</MudText>
|
||||
</div>
|
||||
<MudTextField @bind-Value="_model.AudioBufferSize" For="@(() => _model.AudioBufferSize)" Adornment="Adornment.End" AdornmentText="kBit"/>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Channels</MudText>
|
||||
</div>
|
||||
<MudTextField @bind-Value="_model.AudioChannels" For="@(() => _model.AudioChannels)"/>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Sample Rate</MudText>
|
||||
</div>
|
||||
<MudTextField @bind-Value="_model.AudioSampleRate" For="@(() => _model.AudioSampleRate)" Adornment="Adornment.End" AdornmentText="kHz"/>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
|
||||
<div class="d-flex justify-md-end">
|
||||
<MudText>Normalize Loudness</MudText>
|
||||
</div>
|
||||
<MudSelect @bind-Value="_model.NormalizeLoudnessMode" For="@(() => _model.NormalizeLoudnessMode)">
|
||||
<MudSelectItem Value="@NormalizeLoudnessMode.Off">Off</MudSelectItem>
|
||||
<MudSelectItem Value="@NormalizeLoudnessMode.LoudNorm">loudnorm</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudStack>
|
||||
</MudContainer>
|
||||
</div>
|
||||
</MudForm>
|
||||
|
||||
@code {
|
||||
private readonly CancellationTokenSource _cts = new();
|
||||
@@ -220,8 +275,8 @@
|
||||
public int Id { get; set; }
|
||||
|
||||
private FFmpegProfileEditViewModel _model = new();
|
||||
private EditContext _editContext;
|
||||
private ValidationMessageStore _messageStore;
|
||||
private readonly FFmpegProfileEditViewModelValidator _validator = new();
|
||||
private MudForm _form;
|
||||
|
||||
private List<ResolutionViewModel> _resolutions = new();
|
||||
private List<HardwareAccelerationKind> _hardwareAccelerationKinds = new();
|
||||
@@ -294,9 +349,6 @@
|
||||
_model.HardwareAcceleration = HardwareAccelerationKind.None;
|
||||
}
|
||||
|
||||
_editContext = new EditContext(_model);
|
||||
_messageStore = new ValidationMessageStore(_editContext);
|
||||
|
||||
if (!MemoryCache.TryGetValue("ffmpeg.render_devices", out List<string> vaapiDevices))
|
||||
{
|
||||
vaapiDevices = ["/dev/dri/renderD128"];
|
||||
@@ -325,8 +377,9 @@
|
||||
|
||||
private async Task HandleSubmitAsync()
|
||||
{
|
||||
_messageStore.Clear();
|
||||
if (_editContext.Validate())
|
||||
await _form.Validate();
|
||||
ValidationResult result = await _validator.ValidateAsync(_model, _cts.Token);
|
||||
if (result.IsValid)
|
||||
{
|
||||
Seq<BaseError> errorMessage = IsEdit ? (await Mediator.Send(_model.ToUpdate(), _cts.Token)).LeftToSeq() : (await Mediator.Send(_model.ToCreate(), _cts.Token)).LeftToSeq();
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using ErsatzTV.Core.Domain;
|
||||
using ErsatzTV.ViewModels;
|
||||
using FluentValidation;
|
||||
using FluentValidation.Results;
|
||||
|
||||
namespace ErsatzTV.Validators;
|
||||
|
||||
@@ -97,4 +98,12 @@ public class FFmpegProfileEditViewModelValidator : AbstractValidator<FFmpegProfi
|
||||
.Must(bd => bd is FFmpegProfileBitDepth.EightBit)
|
||||
.WithMessage("Mpeg2Video does not support 10-bit content"));
|
||||
}
|
||||
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
ValidationResult result = await ValidateAsync(ValidationContext<FFmpegProfileEditViewModel>.CreateWithOptions((FFmpegProfileEditViewModel)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return [];
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user