diff --git a/CHANGELOG.md b/CHANGELOG.md index bcaa8cb5c..b887d9101 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Show song artist in playout detail - Include song artist and cover art in channel guide (xmltv) +### Changed +- Randomly place song cover art on left or right side of screen + ## [0.3.0-alpha] - 2021-11-25 ### Fixed - Properly fix database incompatibility introduced with `v0.2.4-alpha` and partially fixed with `v0.2.5-alpha` diff --git a/ErsatzTV.Core/FFmpeg/FFmpegComplexFilterBuilder.cs b/ErsatzTV.Core/FFmpeg/FFmpegComplexFilterBuilder.cs index e08cdd9c8..81bfc0a3d 100644 --- a/ErsatzTV.Core/FFmpeg/FFmpegComplexFilterBuilder.cs +++ b/ErsatzTV.Core/FFmpeg/FFmpegComplexFilterBuilder.cs @@ -118,9 +118,27 @@ namespace ErsatzTV.Core.FFmpeg .Replace(@":/", @"\\:/"); } - // TODO: calculate by percent + var horizontalMarginPercent = 3; + const int VERTICAL_MARGIN_PERCENT = 14; + + foreach (ChannelWatermark watermark in _watermark) + { + horizontalMarginPercent = watermark.HorizontalMarginPercent; + switch (watermark.Location) + { + case ChannelWatermarkLocation.BottomLeft: + horizontalMarginPercent += watermark.WidthPercent + watermark.HorizontalMarginPercent; + break; + } + } + + double horizontalMargin = Math.Round(horizontalMarginPercent / 100.0 * _resolution.Width); + double verticalMargin = Math.Round(VERTICAL_MARGIN_PERCENT / 100.0 * _resolution.Height); + + var location = $"x={horizontalMargin}:y=H-{verticalMargin}"; + _drawtext = - $"drawtext=fontfile={fontPath}:textfile={effectiveFile}:x=50:y=H-175:fontsize=36:fontcolor=white"; + $"drawtext=fontfile={fontPath}:textfile={effectiveFile}:{location}:fontsize=36:fontcolor=white"; } } diff --git a/ErsatzTV.Core/FFmpeg/FFmpegProcessService.cs b/ErsatzTV.Core/FFmpeg/FFmpegProcessService.cs index ca795ae8d..d402233d4 100644 --- a/ErsatzTV.Core/FFmpeg/FFmpegProcessService.cs +++ b/ErsatzTV.Core/FFmpeg/FFmpegProcessService.cs @@ -19,6 +19,7 @@ namespace ErsatzTV.Core.FFmpeg private readonly ITempFilePool _tempFilePool; private readonly ILogger _logger; private readonly FFmpegPlaybackSettingsCalculator _playbackSettingsCalculator; + private readonly Random _random = new(); public FFmpegProcessService( FFmpegPlaybackSettingsCalculator ffmpegPlaybackSettingsService, @@ -270,7 +271,6 @@ namespace ErsatzTV.Core.FFmpeg .WithThreads(1) .WithQuiet() .WithFormatFlags(playbackSettings.FormatFlags) - .WithRealtimeOutput(playbackSettings.RealtimeOutput) .WithSongInput(videoPath, videoStream.Codec, videoStream.PixelFormat) .WithWatermark(watermarkOptions, channel.FFmpegProfile.Resolution) .WithDrawtextFile(videoVersion, drawtextFile); @@ -330,7 +330,9 @@ namespace ErsatzTV.Core.FFmpeg Mode = ChannelWatermarkMode.Permanent, HorizontalMarginPercent = 3, VerticalMarginPercent = 5, - Location = ChannelWatermarkLocation.BottomRight, + Location = _random.Next() % 2 == 0 + ? ChannelWatermarkLocation.BottomRight + : ChannelWatermarkLocation.BottomLeft, Size = ChannelWatermarkSize.Scaled, WidthPercent = 25, Opacity = 100