diff --git a/CHANGELOG.md b/CHANGELOG.md index 83bb6af37..187fa6708 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/ErsatzTV.FFmpeg.Tests/Filter/WatermarkOpacityFilterTests.cs b/ErsatzTV.FFmpeg.Tests/Filter/WatermarkOpacityFilterTests.cs new file mode 100644 index 000000000..bc568643b --- /dev/null +++ b/ErsatzTV.FFmpeg.Tests/Filter/WatermarkOpacityFilterTests.cs @@ -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>.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>.None, + WatermarkLocation.BottomRight, + WatermarkSize.ActualSize, + 50, + 50, + 50, + 75)); + + filter.Filter.Should().Be("colorchannelmixer=aa=0.75"); + } +} diff --git a/ErsatzTV.FFmpeg/Filter/WatermarkOpacityFilter.cs b/ErsatzTV.FFmpeg/Filter/WatermarkOpacityFilter.cs index 5e73662ea..2bfc8be37 100644 --- a/ErsatzTV.FFmpeg/Filter/WatermarkOpacityFilter.cs +++ b/ErsatzTV.FFmpeg/Filter/WatermarkOpacityFilter.cs @@ -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 get { double opacity = _desiredState.Opacity / 100.0; - return $"colorchannelmixer=aa={opacity:F2}"; + return $"colorchannelmixer=aa={opacity.ToString("F2", NumberFormatInfo.InvariantInfo)}"; } }