Browse Source

maintain source fps when using qsv (#2558)

pull/2559/head
Jason Dove 9 months ago committed by GitHub
parent
commit
82e0fcaec8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      ErsatzTV.Application/Troubleshooting/Commands/PrepareTroubleshootingPlaybackHandler.cs
  2. 4
      ErsatzTV.FFmpeg/Filter/ResetPtsFilter.cs
  3. 21
      ErsatzTV.FFmpeg/Pipeline/QsvPipelineBuilder.cs

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

@ -248,7 +248,7 @@ public class PrepareTroubleshootingPlaybackHandler(
inPoint, inPoint,
channelStartTime: DateTimeOffset.Now, channelStartTime: DateTimeOffset.Now,
TimeSpan.Zero, TimeSpan.Zero,
None, Option<int>.None,
FileSystemLayout.TranscodeTroubleshootingFolder, FileSystemLayout.TranscodeTroubleshootingFolder,
_ => { }, _ => { },
cancellationToken); cancellationToken);

4
ErsatzTV.FFmpeg/Filter/ResetPtsFilter.cs

@ -1,8 +1,8 @@
namespace ErsatzTV.FFmpeg.Filter; namespace ErsatzTV.FFmpeg.Filter;
public class ResetPtsFilter : BaseFilter public class ResetPtsFilter(string fps) : BaseFilter
{ {
public override string Filter => "setpts=PTS-STARTPTS"; public override string Filter => $"setpts=PTS-STARTPTS,fps={fps}";
public override FrameState NextState(FrameState currentState) => currentState; public override FrameState NextState(FrameState currentState) => currentState;
} }

21
ErsatzTV.FFmpeg/Pipeline/QsvPipelineBuilder.cs

@ -1,3 +1,4 @@
using System.Globalization;
using ErsatzTV.FFmpeg.Capabilities; using ErsatzTV.FFmpeg.Capabilities;
using ErsatzTV.FFmpeg.Decoder; using ErsatzTV.FFmpeg.Decoder;
using ErsatzTV.FFmpeg.Decoder.Qsv; using ErsatzTV.FFmpeg.Decoder.Qsv;
@ -170,8 +171,6 @@ public class QsvPipelineBuilder : SoftwarePipelineBuilder
currentState = decoder.NextState(currentState); currentState = decoder.NextState(currentState);
} }
videoInputFile.FilterSteps.Add(new ResetPtsFilter());
// easier to use nv12 for overlay // easier to use nv12 for overlay
if (context.HasSubtitleOverlay || context.HasWatermark || context.HasGraphicsEngine) if (context.HasSubtitleOverlay || context.HasWatermark || context.HasGraphicsEngine)
{ {
@ -194,15 +193,27 @@ public class QsvPipelineBuilder : SoftwarePipelineBuilder
currentState = SetCrop(videoInputFile, desiredState, currentState); currentState = SetCrop(videoInputFile, desiredState, currentState);
SetStillImageLoop(videoInputFile, videoStream, ffmpegState, desiredState, pipelineSteps); SetStillImageLoop(videoInputFile, videoStream, ffmpegState, desiredState, pipelineSteps);
// need to download for any sort of overlay // need to download for any sort of overlay (and always for setpts)
if (currentState.FrameDataLocation == FrameDataLocation.Hardware && if (currentState.FrameDataLocation == FrameDataLocation.Hardware) //&&
(context.HasSubtitleOverlay || context.HasWatermark || context.HasGraphicsEngine)) //(context.HasSubtitleOverlay || context.HasWatermark || context.HasGraphicsEngine))
{ {
var hardwareDownload = new HardwareDownloadFilter(currentState); var hardwareDownload = new HardwareDownloadFilter(currentState);
currentState = hardwareDownload.NextState(currentState); currentState = hardwareDownload.NextState(currentState);
videoInputFile.FilterSteps.Add(hardwareDownload); videoInputFile.FilterSteps.Add(hardwareDownload);
} }
// use normalized fps, or source fps
string fps = desiredState.FrameRate.Match(
r => r.ToString(NumberFormatInfo.InvariantInfo),
() => videoStream.FrameRate.IfNone("24"));
videoInputFile.FilterSteps.Add(new ResetPtsFilter(fps));
// since fps will set frame rate, remove the output option
foreach (var frameRate in pipelineSteps.OfType<FrameRateOutputOption>().HeadOrNone())
{
pipelineSteps.Remove(frameRate);
}
currentState = SetSubtitle( currentState = SetSubtitle(
videoInputFile, videoInputFile,
subtitleInputFile, subtitleInputFile,

Loading…
Cancel
Save