Browse Source

work around buggy radeonsi hevc_vaapi behavior (#2680)

* try to workaround amd crop metadata ffmpeg bug

* limit workaround to hevc_vaapi encoder

* update changelog
pull/2683/head
Jason Dove 1 month ago committed by GitHub
parent
commit
42bcadf936
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 34
      ErsatzTV.FFmpeg/OutputOption/AmdCropMetadataWorkaroundFilter.cs
  3. 9
      ErsatzTV.FFmpeg/Pipeline/VaapiPipelineBuilder.cs

1
CHANGELOG.md

@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix detection of Plex Other Video libraries using `Plex Personal Media` agent
- If the library is already detected as a Movies library in ETV, synchronization must be disabled for the library to change it to an Other Videos library
- A warning will be logged when this scenario is detected
- VAAPI: work around buggy ffmpeg behavior where hevc_vaapi encoder with RadeonSI driver incorrectly outputs height of 1088 instead of 1080
## [25.9.0] - 2025-11-29
### Added

34
ErsatzTV.FFmpeg/OutputOption/AmdCropMetadataWorkaroundFilter.cs

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
using ErsatzTV.FFmpeg.Format;
namespace ErsatzTV.FFmpeg.OutputOption;
public class AmdCropMetadataWorkaroundFilter(string videoFormat, FrameSize frameSize) : OutputOption
{
public override string[] OutputOptions
{
get
{
if (videoFormat is not VideoFormat.Hevc)
{
return [];
}
int cropPixels = frameSize.Height switch
{
1080 => 8,
_ => 0
};
if (cropPixels == 0)
{
return [];
}
return
[
"-bsf:v",
$"{videoFormat}_metadata=crop_bottom={cropPixels}"
];
}
}
}

9
ErsatzTV.FFmpeg/Pipeline/VaapiPipelineBuilder.cs

@ -283,6 +283,15 @@ public class VaapiPipelineBuilder : SoftwarePipelineBuilder @@ -283,6 +283,15 @@ public class VaapiPipelineBuilder : SoftwarePipelineBuilder
currentState,
pipelineSteps);
if (ffmpegState.VaapiDriver == "radeonsi" &&
ffmpegState.EncoderHardwareAccelerationMode is HardwareAccelerationMode.Vaapi)
{
pipelineSteps.Add(
new AmdCropMetadataWorkaroundFilter(
desiredState.VideoFormat,
desiredState.CroppedSize.IfNone(desiredState.PaddedSize)));
}
return new FilterChain(
videoInputFile.FilterSteps,
watermarkInputFile.Map(wm => wm.FilterSteps).IfNone([]),

Loading…
Cancel
Save