Browse Source

fix graphics engine on vaapi (#2281)

pull/2282/head
Jason Dove 12 months ago committed by GitHub
parent
commit
9f3db05c17
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      ErsatzTV.Application/Troubleshooting/Commands/PrepareTroubleshootingPlaybackHandler.cs
  2. 4
      ErsatzTV.Core/Scheduling/YamlScheduling/YamlPlayoutContext.cs
  3. 13
      ErsatzTV.FFmpeg/Filter/Vaapi/OverlayGraphicsEngineVaapiFilter.cs
  4. 12
      ErsatzTV.FFmpeg/Pipeline/VaapiPipelineBuilder.cs
  5. 2
      ErsatzTV/Pages/PlaybackTroubleshooting.razor

5
ErsatzTV.Application/Troubleshooting/Commands/PrepareTroubleshootingPlaybackHandler.cs

@ -11,6 +11,7 @@ using ErsatzTV.Core.Interfaces.Jellyfin;
using ErsatzTV.Core.Interfaces.Locking; using ErsatzTV.Core.Interfaces.Locking;
using ErsatzTV.Core.Interfaces.Metadata; using ErsatzTV.Core.Interfaces.Metadata;
using ErsatzTV.Core.Interfaces.Plex; using ErsatzTV.Core.Interfaces.Plex;
using ErsatzTV.Core.Notifications;
using ErsatzTV.FFmpeg; using ErsatzTV.FFmpeg;
using ErsatzTV.Infrastructure.Data; using ErsatzTV.Infrastructure.Data;
using ErsatzTV.Infrastructure.Extensions; using ErsatzTV.Infrastructure.Extensions;
@ -27,6 +28,7 @@ public class PrepareTroubleshootingPlaybackHandler(
IFFmpegProcessService ffmpegProcessService, IFFmpegProcessService ffmpegProcessService,
ILocalFileSystem localFileSystem, ILocalFileSystem localFileSystem,
IEntityLocker entityLocker, IEntityLocker entityLocker,
IMediator mediator,
ILogger<PrepareTroubleshootingPlaybackHandler> logger) ILogger<PrepareTroubleshootingPlaybackHandler> logger)
: IRequestHandler<PrepareTroubleshootingPlayback, Either<BaseError, PlayoutItemResult>> : IRequestHandler<PrepareTroubleshootingPlayback, Either<BaseError, PlayoutItemResult>>
{ {
@ -43,6 +45,7 @@ public class PrepareTroubleshootingPlaybackHandler(
catch (Exception ex) catch (Exception ex)
{ {
entityLocker.UnlockTroubleshootingPlayback(); entityLocker.UnlockTroubleshootingPlayback();
await mediator.Publish(new PlaybackTroubleshootingCompletedNotification(-1), cancellationToken);
logger.LogError(ex, "Error while preparing troubleshooting playback"); logger.LogError(ex, "Error while preparing troubleshooting playback");
return BaseError.New(ex.Message); return BaseError.New(ex.Message);
} }
@ -116,6 +119,8 @@ public class PrepareTroubleshootingPlaybackHandler(
true, true,
new Channel(Guid.Empty) new Channel(Guid.Empty)
{ {
Artwork = [],
Name = "ETV",
Number = ".troubleshooting", Number = ".troubleshooting",
FFmpegProfile = ffmpegProfile, FFmpegProfile = ffmpegProfile,
StreamingMode = StreamingMode.HttpLiveStreamingSegmenter, StreamingMode = StreamingMode.HttpLiveStreamingSegmenter,

4
ErsatzTV.Core/Scheduling/YamlScheduling/YamlPlayoutContext.cs

@ -178,6 +178,10 @@ public class YamlPlayoutContext(Playout playout, YamlPlayoutDefinition definitio
} }
State state = JsonConvert.DeserializeObject<State>(anchor.Context); State state = JsonConvert.DeserializeObject<State>(anchor.Context);
if (state.ChannelWatermarkIds is null)
{
state = state with { ChannelWatermarkIds = [] };
}
foreach (int instructionIndex in Optional(state.InstructionIndex)) foreach (int instructionIndex in Optional(state.InstructionIndex))
{ {

13
ErsatzTV.FFmpeg/Filter/Vaapi/OverlayGraphicsEngineVaapiFilter.cs

@ -0,0 +1,13 @@
using ErsatzTV.FFmpeg.Format;
namespace ErsatzTV.FFmpeg.Filter.Vaapi;
public class OverlayGraphicsEngineVaapiFilter(FrameState currentState, IPixelFormat outputPixelFormat) : BaseFilter
{
public override string Filter =>
currentState.FrameDataLocation is FrameDataLocation.Hardware
? "overlay_vaapi"
: $"overlay=format={(outputPixelFormat.BitDepth == 10 ? '1' : '0')}";
public override FrameState NextState(FrameState currentState) => currentState;
}

12
ErsatzTV.FFmpeg/Pipeline/VaapiPipelineBuilder.cs

@ -230,7 +230,7 @@ public class VaapiPipelineBuilder : SoftwarePipelineBuilder
currentState, currentState,
watermarkOverlayFilterSteps); watermarkOverlayFilterSteps);
SetGraphicsEngine(graphicsEngineInput, desiredState, graphicsEngineOverlayFilterSteps); SetGraphicsEngine(graphicsEngineInput, currentState, desiredState, graphicsEngineOverlayFilterSteps);
// after everything else is done, apply the encoder // after everything else is done, apply the encoder
if (pipelineSteps.OfType<IEncoder>().All(e => e.Kind != StreamKind.Video)) if (pipelineSteps.OfType<IEncoder>().All(e => e.Kind != StreamKind.Video))
@ -538,10 +538,11 @@ public class VaapiPipelineBuilder : SoftwarePipelineBuilder
private static void SetGraphicsEngine( private static void SetGraphicsEngine(
Option<GraphicsEngineInput> graphicsEngineInput, Option<GraphicsEngineInput> graphicsEngineInput,
FrameState currentState,
FrameState desiredState, FrameState desiredState,
List<IPipelineFilterStep> graphicsEngineOverlayFilterSteps) List<IPipelineFilterStep> graphicsEngineOverlayFilterSteps)
{ {
foreach (var _ in graphicsEngineInput) foreach (var graphicsEngine in graphicsEngineInput)
{ {
foreach (IPixelFormat desiredPixelFormat in desiredState.PixelFormat) foreach (IPixelFormat desiredPixelFormat in desiredState.PixelFormat)
{ {
@ -554,7 +555,12 @@ public class VaapiPipelineBuilder : SoftwarePipelineBuilder
} }
} }
graphicsEngineOverlayFilterSteps.Add(new OverlayGraphicsEngineFilter(pf)); if (currentState.FrameDataLocation is FrameDataLocation.Hardware)
{
graphicsEngine.FilterSteps.Add(new HardwareUploadVaapiFilter(false));
}
graphicsEngineOverlayFilterSteps.Add(new OverlayGraphicsEngineVaapiFilter(currentState, pf));
} }
} }
} }

2
ErsatzTV/Pages/PlaybackTroubleshooting.razor

@ -145,12 +145,14 @@
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
_ffmpegProfiles.Clear();
_ffmpegProfiles.AddRange(await Mediator.Send(new GetAllFFmpegProfiles(), _cts.Token)); _ffmpegProfiles.AddRange(await Mediator.Send(new GetAllFFmpegProfiles(), _cts.Token));
if (_ffmpegProfiles.Count > 0) if (_ffmpegProfiles.Count > 0)
{ {
_ffmpegProfileId = _ffmpegProfiles.Map(f => f.Id).Head(); _ffmpegProfileId = _ffmpegProfiles.Map(f => f.Id).Head();
} }
_watermarks.Clear();
_watermarks.AddRange(await Mediator.Send(new GetAllWatermarks(), _cts.Token)); _watermarks.AddRange(await Mediator.Send(new GetAllWatermarks(), _cts.Token));
if (MediaItemId is not null) if (MediaItemId is not null)

Loading…
Cancel
Save