Browse Source

fix watermark opacity filter (#820)

pull/824/head
Jason Dove 4 years ago committed by GitHub
parent
commit
4e2ebcc48a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 47
      ErsatzTV.FFmpeg.Tests/Filter/WatermarkOpacityFilterTests.cs
  3. 5
      ErsatzTV.FFmpeg/Filter/WatermarkOpacityFilter.cs

1
CHANGELOG.md

@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Fixed
- Additional fix for duplicate `Other Videos` entries; trash may need to be emptied one last time after upgrading
- Fix watermark opacity in cultures where `,` is a decimal separator
### Added
- Enable QSV hardware acceleration for vaapi docker images

47
ErsatzTV.FFmpeg.Tests/Filter/WatermarkOpacityFilterTests.cs

@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
using System.Collections.Generic;
using ErsatzTV.FFmpeg.Filter;
using ErsatzTV.FFmpeg.State;
using FluentAssertions;
using LanguageExt;
using NUnit.Framework;
namespace ErsatzTV.FFmpeg.Tests.Filter;
[TestFixture]
public class WatermarkOpacityFilterTests
{
[Test]
// this needs to be a culture where ',' is a decimal separator
[SetCulture("it-IT")]
public void Should_Return_Filter_With_Period_Decimal_Unlike_Local_Culture()
{
var filter = new WatermarkOpacityFilter(
new WatermarkState(
Option<List<WatermarkFadePoint>>.None,
WatermarkLocation.BottomRight,
WatermarkSize.ActualSize,
50,
50,
50,
75));
filter.Filter.Should().Be("colorchannelmixer=aa=0.75");
}
[Test]
[SetCulture("en-US")]
public void Should_Return_Filter_With_Period_Decimal()
{
var filter = new WatermarkOpacityFilter(
new WatermarkState(
Option<List<WatermarkFadePoint>>.None,
WatermarkLocation.BottomRight,
WatermarkSize.ActualSize,
50,
50,
50,
75));
filter.Filter.Should().Be("colorchannelmixer=aa=0.75");
}
}

5
ErsatzTV.FFmpeg/Filter/WatermarkOpacityFilter.cs

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
using ErsatzTV.FFmpeg.State;
using System.Globalization;
using ErsatzTV.FFmpeg.State;
namespace ErsatzTV.FFmpeg.Filter;
@ -13,7 +14,7 @@ public class WatermarkOpacityFilter : BaseFilter @@ -13,7 +14,7 @@ public class WatermarkOpacityFilter : BaseFilter
get
{
double opacity = _desiredState.Opacity / 100.0;
return $"colorchannelmixer=aa={opacity:F2}";
return $"colorchannelmixer=aa={opacity.ToString("F2", NumberFormatInfo.InvariantInfo)}";
}
}

Loading…
Cancel
Save