Browse Source

add qsv extra hardware frames setting (#950)

* wip add qsv extra_hw_frames setting

* fix ffmpeg profile editor

* update changelog
pull/951/head
Jason Dove 3 years ago committed by GitHub
parent
commit
f1be945423
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 1
      ErsatzTV.Application/FFmpegProfiles/Commands/CreateFFmpegProfile.cs
  3. 1
      ErsatzTV.Application/FFmpegProfiles/Commands/CreateFFmpegProfileHandler.cs
  4. 2
      ErsatzTV.Application/FFmpegProfiles/Commands/NewFFmpegProfileHandler.cs
  5. 1
      ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegProfile.cs
  6. 3
      ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegProfileHandler.cs
  7. 1
      ErsatzTV.Application/FFmpegProfiles/FFmpegProfileViewModel.cs
  8. 1
      ErsatzTV.Application/FFmpegProfiles/Mapper.cs
  9. 3
      ErsatzTV.Application/Streaming/Queries/GetErrorProcessHandler.cs
  10. 10
      ErsatzTV.Application/Streaming/Queries/GetPlayoutItemProcessByChannelNumberHandler.cs
  11. 1
      ErsatzTV.Core.Tests/FFmpeg/TranscodingTests.cs
  12. 4
      ErsatzTV.Core/Domain/FFmpegProfile.cs
  13. 8
      ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs
  14. 4
      ErsatzTV.Core/Interfaces/FFmpeg/IFFmpegProcessService.cs
  15. 4306
      ErsatzTV.Infrastructure/Migrations/20220904224409_Add_FFmpegProfileQsvExtraHardwareFrames.Designer.cs
  16. 26
      ErsatzTV.Infrastructure/Migrations/20220904224409_Add_FFmpegProfileQsvExtraHardwareFrames.cs
  17. 3
      ErsatzTV.Infrastructure/Migrations/TvContextModelSnapshot.cs
  18. 3
      ErsatzTV/Pages/FFmpegEditor.razor
  19. 4
      ErsatzTV/ViewModels/FFmpegProfileEditViewModel.cs

1
CHANGELOG.md

@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- This can be helpful for creating channels that use commentary tracks
- External tooling exists to easily update title/name metadata if your audio streams don't already have this metadata
- Add `Amf` hardware acceleration option for AMD GPUs on Windows
- Add `QSV Extra Hardware Frames` parameter for tuning QSV acceleration; some systems may run better after doubling or halving the default value of `64`
## [0.6.6-beta] - 2022-08-17
### Fixed

1
ErsatzTV.Application/FFmpegProfiles/Commands/CreateFFmpegProfile.cs

@ -10,6 +10,7 @@ public record CreateFFmpegProfile( @@ -10,6 +10,7 @@ public record CreateFFmpegProfile(
HardwareAccelerationKind HardwareAcceleration,
VaapiDriver VaapiDriver,
string VaapiDevice,
int? QsvExtraHardwareFrames,
int ResolutionId,
FFmpegProfileVideoFormat VideoFormat,
int VideoBitrate,

1
ErsatzTV.Application/FFmpegProfiles/Commands/CreateFFmpegProfileHandler.cs

@ -44,6 +44,7 @@ public class CreateFFmpegProfileHandler : @@ -44,6 +44,7 @@ public class CreateFFmpegProfileHandler :
HardwareAcceleration = request.HardwareAcceleration,
VaapiDriver = request.VaapiDriver,
VaapiDevice = request.VaapiDevice,
QsvExtraHardwareFrames = request.QsvExtraHardwareFrames,
ResolutionId = resolutionId,
VideoFormat = request.VideoFormat,
VideoBitrate = request.VideoBitrate,

2
ErsatzTV.Application/FFmpegProfiles/Commands/NewFFmpegProfileHandler.cs

@ -15,7 +15,7 @@ public class NewFFmpegProfileHandler : IRequestHandler<NewFFmpegProfile, FFmpegP @@ -15,7 +15,7 @@ public class NewFFmpegProfileHandler : IRequestHandler<NewFFmpegProfile, FFmpegP
public async Task<FFmpegProfileViewModel> Handle(NewFFmpegProfile request, CancellationToken cancellationToken)
{
await using TvContext dbContext = _dbContextFactory.CreateDbContext();
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
int defaultResolutionId = await dbContext.ConfigElements
.GetValue<int>(ConfigElementKey.FFmpegDefaultResolutionId)

1
ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegProfile.cs

@ -11,6 +11,7 @@ public record UpdateFFmpegProfile( @@ -11,6 +11,7 @@ public record UpdateFFmpegProfile(
HardwareAccelerationKind HardwareAcceleration,
VaapiDriver VaapiDriver,
string VaapiDevice,
int? QsvExtraHardwareFrames,
int ResolutionId,
FFmpegProfileVideoFormat VideoFormat,
int VideoBitrate,

3
ErsatzTV.Application/FFmpegProfiles/Commands/UpdateFFmpegProfileHandler.cs

@ -20,7 +20,7 @@ public class @@ -20,7 +20,7 @@ public class
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, FFmpegProfile> validation = await Validate(dbContext, request);
return await LanguageExtensions.Apply(validation, p => ApplyUpdateRequest(dbContext, p, request));
return await validation.Apply(p => ApplyUpdateRequest(dbContext, p, request));
}
private async Task<UpdateFFmpegProfileResult> ApplyUpdateRequest(
@ -33,6 +33,7 @@ public class @@ -33,6 +33,7 @@ public class
p.HardwareAcceleration = update.HardwareAcceleration;
p.VaapiDriver = update.VaapiDriver;
p.VaapiDevice = update.VaapiDevice;
p.QsvExtraHardwareFrames = update.QsvExtraHardwareFrames;
p.ResolutionId = update.ResolutionId;
p.VideoFormat = update.VideoFormat;
p.VideoBitrate = update.VideoBitrate;

1
ErsatzTV.Application/FFmpegProfiles/FFmpegProfileViewModel.cs

@ -11,6 +11,7 @@ public record FFmpegProfileViewModel( @@ -11,6 +11,7 @@ public record FFmpegProfileViewModel(
HardwareAccelerationKind HardwareAcceleration,
VaapiDriver VaapiDriver,
string VaapiDevice,
int? QsvExtraHardwareFrames,
ResolutionViewModel Resolution,
FFmpegProfileVideoFormat VideoFormat,
int VideoBitrate,

1
ErsatzTV.Application/FFmpegProfiles/Mapper.cs

@ -14,6 +14,7 @@ internal static class Mapper @@ -14,6 +14,7 @@ internal static class Mapper
profile.HardwareAcceleration,
profile.VaapiDriver,
profile.VaapiDevice,
profile.QsvExtraHardwareFrames,
Project(profile.Resolution),
profile.VideoFormat,
profile.VideoBitrate,

3
ErsatzTV.Application/Streaming/Queries/GetErrorProcessHandler.cs

@ -33,7 +33,8 @@ public class GetErrorProcessHandler : FFmpegProcessHandler<GetErrorProcess> @@ -33,7 +33,8 @@ public class GetErrorProcessHandler : FFmpegProcessHandler<GetErrorProcess>
request.HlsRealtime,
request.PtsOffset,
channel.FFmpegProfile.VaapiDriver,
channel.FFmpegProfile.VaapiDevice);
channel.FFmpegProfile.VaapiDevice,
Optional(channel.FFmpegProfile.QsvExtraHardwareFrames));
return new PlayoutItemProcessModel(process, request.MaybeDuration, request.Until);
}

10
ErsatzTV.Application/Streaming/Queries/GetPlayoutItemProcessByChannelNumberHandler.cs

@ -184,6 +184,7 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler< @@ -184,6 +184,7 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler<
maybeGlobalWatermark,
channel.FFmpegProfile.VaapiDriver,
channel.FFmpegProfile.VaapiDevice,
Optional(channel.FFmpegProfile.QsvExtraHardwareFrames),
request.HlsRealtime,
playoutItemWithPath.PlayoutItem.FillerKind,
playoutItemWithPath.PlayoutItem.InPoint,
@ -230,7 +231,8 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler< @@ -230,7 +231,8 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler<
request.HlsRealtime,
request.PtsOffset,
channel.FFmpegProfile.VaapiDriver,
channel.FFmpegProfile.VaapiDevice);
channel.FFmpegProfile.VaapiDevice,
Optional(channel.FFmpegProfile.QsvExtraHardwareFrames));
return new PlayoutItemProcessModel(offlineProcess, maybeDuration, finish);
case PlayoutItemDoesNotExistOnDisk:
@ -242,7 +244,8 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler< @@ -242,7 +244,8 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler<
request.HlsRealtime,
request.PtsOffset,
channel.FFmpegProfile.VaapiDriver,
channel.FFmpegProfile.VaapiDevice);
channel.FFmpegProfile.VaapiDevice,
Optional(channel.FFmpegProfile.QsvExtraHardwareFrames));
return new PlayoutItemProcessModel(doesNotExistProcess, maybeDuration, finish);
default:
@ -254,7 +257,8 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler< @@ -254,7 +257,8 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler<
request.HlsRealtime,
request.PtsOffset,
channel.FFmpegProfile.VaapiDriver,
channel.FFmpegProfile.VaapiDevice);
channel.FFmpegProfile.VaapiDevice,
Optional(channel.FFmpegProfile.QsvExtraHardwareFrames));
return new PlayoutItemProcessModel(errorProcess, maybeDuration, finish);
}

1
ErsatzTV.Core.Tests/FFmpeg/TranscodingTests.cs

@ -499,6 +499,7 @@ public class TranscodingTests @@ -499,6 +499,7 @@ public class TranscodingTests
channelWatermark,
VaapiDriver.Default,
"/dev/dri/renderD128",
Option<int>.None,
false,
FillerKind.None,
TimeSpan.Zero,

4
ErsatzTV.Core/Domain/FFmpegProfile.cs

@ -10,6 +10,7 @@ public record FFmpegProfile @@ -10,6 +10,7 @@ public record FFmpegProfile
public HardwareAccelerationKind HardwareAcceleration { get; set; }
public VaapiDriver VaapiDriver { get; set; }
public string VaapiDevice { get; set; }
public int? QsvExtraHardwareFrames { get; set; }
public int ResolutionId { get; set; }
public Resolution Resolution { get; set; }
public FFmpegProfileVideoFormat VideoFormat { get; set; }
@ -42,6 +43,7 @@ public record FFmpegProfile @@ -42,6 +43,7 @@ public record FFmpegProfile
AudioSampleRate = 48,
DeinterlaceVideo = true,
NormalizeFramerate = false,
HardwareAcceleration = HardwareAccelerationKind.None
HardwareAcceleration = HardwareAccelerationKind.None,
QsvExtraHardwareFrames = 64
};
}

8
ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs

@ -63,6 +63,7 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService @@ -63,6 +63,7 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService
Option<ChannelWatermark> globalWatermark,
VaapiDriver vaapiDriver,
string vaapiDevice,
Option<int> qsvExtraHardwareFrames,
bool hlsRealtime,
FillerKind fillerKind,
TimeSpan inPoint,
@ -240,7 +241,7 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService @@ -240,7 +241,7 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService
hlsSegmentTemplate,
ptsOffset,
playbackSettings.ThreadCount,
128);
qsvExtraHardwareFrames);
_logger.LogDebug("FFmpeg desired state {FrameState}", desiredState);
@ -268,7 +269,8 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService @@ -268,7 +269,8 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService
bool hlsRealtime,
long ptsOffset,
VaapiDriver vaapiDriver,
string vaapiDevice)
string vaapiDevice,
Option<int> qsvExtraHardwareFrames)
{
FFmpegPlaybackSettings playbackSettings = _playbackSettingsCalculator.CalculateErrorSettings(
channel.StreamingMode,
@ -365,7 +367,7 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService @@ -365,7 +367,7 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService
hlsSegmentTemplate,
ptsOffset,
Option<int>.None,
128);
qsvExtraHardwareFrames);
var ffmpegSubtitleStream = new ErsatzTV.FFmpeg.MediaStream(0, "ass", StreamKind.Video);

4
ErsatzTV.Core/Interfaces/FFmpeg/IFFmpegProcessService.cs

@ -29,6 +29,7 @@ public interface IFFmpegProcessService @@ -29,6 +29,7 @@ public interface IFFmpegProcessService
Option<ChannelWatermark> globalWatermark,
VaapiDriver vaapiDriver,
string vaapiDevice,
Option<int> qsvExtraHardwareFrames,
bool hlsRealtime,
FillerKind fillerKind,
TimeSpan inPoint,
@ -45,7 +46,8 @@ public interface IFFmpegProcessService @@ -45,7 +46,8 @@ public interface IFFmpegProcessService
bool hlsRealtime,
long ptsOffset,
VaapiDriver vaapiDriver,
string vaapiDevice);
string vaapiDevice,
Option<int> qsvExtraHardwareFrames);
Task<Command> ConcatChannel(string ffmpegPath, bool saveReports, Channel channel, string scheme, string host);

4306
ErsatzTV.Infrastructure/Migrations/20220904224409_Add_FFmpegProfileQsvExtraHardwareFrames.Designer.cs generated

File diff suppressed because it is too large Load Diff

26
ErsatzTV.Infrastructure/Migrations/20220904224409_Add_FFmpegProfileQsvExtraHardwareFrames.cs

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ErsatzTV.Infrastructure.Migrations
{
public partial class Add_FFmpegProfileQsvExtraHardwareFrames : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "QsvExtraHardwareFrames",
table: "FFmpegProfile",
type: "INTEGER",
nullable: true,
defaultValue: 64);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "QsvExtraHardwareFrames",
table: "FFmpegProfile");
}
}
}

3
ErsatzTV.Infrastructure/Migrations/TvContextModelSnapshot.cs

@ -561,6 +561,9 @@ namespace ErsatzTV.Infrastructure.Migrations @@ -561,6 +561,9 @@ namespace ErsatzTV.Infrastructure.Migrations
b.Property<bool>("NormalizeLoudness")
.HasColumnType("INTEGER");
b.Property<int?>("QsvExtraHardwareFrames")
.HasColumnType("INTEGER");
b.Property<int>("ResolutionId")
.HasColumnType("INTEGER");

3
ErsatzTV/Pages/FFmpegEditor.razor

@ -76,6 +76,9 @@ @@ -76,6 +76,9 @@
}
</MudSelect>
</MudElement>
<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>
<MudElement HtmlTag="div" Class="mt-3">
<MudCheckBox Label="Normalize Frame Rate" @bind-Checked="@_model.NormalizeFramerate" For="@(() => _model.NormalizeFramerate)"/>
</MudElement>

4
ErsatzTV/ViewModels/FFmpegProfileEditViewModel.cs

@ -28,6 +28,7 @@ public class FFmpegProfileEditViewModel @@ -28,6 +28,7 @@ public class FFmpegProfileEditViewModel
HardwareAcceleration = viewModel.HardwareAcceleration;
VaapiDriver = viewModel.VaapiDriver;
VaapiDevice = viewModel.VaapiDevice;
QsvExtraHardwareFrames = viewModel.QsvExtraHardwareFrames;
VideoBitrate = viewModel.VideoBitrate;
VideoBufferSize = viewModel.VideoBufferSize;
VideoFormat = viewModel.VideoFormat;
@ -48,6 +49,7 @@ public class FFmpegProfileEditViewModel @@ -48,6 +49,7 @@ public class FFmpegProfileEditViewModel
public HardwareAccelerationKind HardwareAcceleration { get; set; }
public VaapiDriver VaapiDriver { get; set; }
public string VaapiDevice { get; set; }
public int? QsvExtraHardwareFrames { get; set; }
public int VideoBitrate { get; set; }
public int VideoBufferSize { get; set; }
public FFmpegProfileVideoFormat VideoFormat { get; set; }
@ -59,6 +61,7 @@ public class FFmpegProfileEditViewModel @@ -59,6 +61,7 @@ public class FFmpegProfileEditViewModel
HardwareAcceleration,
VaapiDriver,
VaapiDevice,
QsvExtraHardwareFrames,
Resolution.Id,
VideoFormat,
VideoBitrate,
@ -81,6 +84,7 @@ public class FFmpegProfileEditViewModel @@ -81,6 +84,7 @@ public class FFmpegProfileEditViewModel
HardwareAcceleration,
VaapiDriver,
VaapiDevice,
QsvExtraHardwareFrames,
Resolution.Id,
VideoFormat,
VideoBitrate,

Loading…
Cancel
Save