Browse Source

randomize cover art placement (#507)

pull/508/head
Jason Dove 5 years ago committed by GitHub
parent
commit
af51b790b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      CHANGELOG.md
  2. 22
      ErsatzTV.Core/FFmpeg/FFmpegComplexFilterBuilder.cs
  3. 6
      ErsatzTV.Core/FFmpeg/FFmpegProcessService.cs

3
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 - Show song artist in playout detail
- Include song artist and cover art in channel guide (xmltv) - 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 ## [0.3.0-alpha] - 2021-11-25
### Fixed ### Fixed
- Properly fix database incompatibility introduced with `v0.2.4-alpha` and partially fixed with `v0.2.5-alpha` - Properly fix database incompatibility introduced with `v0.2.4-alpha` and partially fixed with `v0.2.5-alpha`

22
ErsatzTV.Core/FFmpeg/FFmpegComplexFilterBuilder.cs

@ -118,9 +118,27 @@ namespace ErsatzTV.Core.FFmpeg
.Replace(@":/", @"\\:/"); .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 =
$"drawtext=fontfile={fontPath}:textfile={effectiveFile}:x=50:y=H-175:fontsize=36:fontcolor=white"; $"drawtext=fontfile={fontPath}:textfile={effectiveFile}:{location}:fontsize=36:fontcolor=white";
} }
} }

6
ErsatzTV.Core/FFmpeg/FFmpegProcessService.cs

@ -19,6 +19,7 @@ namespace ErsatzTV.Core.FFmpeg
private readonly ITempFilePool _tempFilePool; private readonly ITempFilePool _tempFilePool;
private readonly ILogger<FFmpegProcessService> _logger; private readonly ILogger<FFmpegProcessService> _logger;
private readonly FFmpegPlaybackSettingsCalculator _playbackSettingsCalculator; private readonly FFmpegPlaybackSettingsCalculator _playbackSettingsCalculator;
private readonly Random _random = new();
public FFmpegProcessService( public FFmpegProcessService(
FFmpegPlaybackSettingsCalculator ffmpegPlaybackSettingsService, FFmpegPlaybackSettingsCalculator ffmpegPlaybackSettingsService,
@ -270,7 +271,6 @@ namespace ErsatzTV.Core.FFmpeg
.WithThreads(1) .WithThreads(1)
.WithQuiet() .WithQuiet()
.WithFormatFlags(playbackSettings.FormatFlags) .WithFormatFlags(playbackSettings.FormatFlags)
.WithRealtimeOutput(playbackSettings.RealtimeOutput)
.WithSongInput(videoPath, videoStream.Codec, videoStream.PixelFormat) .WithSongInput(videoPath, videoStream.Codec, videoStream.PixelFormat)
.WithWatermark(watermarkOptions, channel.FFmpegProfile.Resolution) .WithWatermark(watermarkOptions, channel.FFmpegProfile.Resolution)
.WithDrawtextFile(videoVersion, drawtextFile); .WithDrawtextFile(videoVersion, drawtextFile);
@ -330,7 +330,9 @@ namespace ErsatzTV.Core.FFmpeg
Mode = ChannelWatermarkMode.Permanent, Mode = ChannelWatermarkMode.Permanent,
HorizontalMarginPercent = 3, HorizontalMarginPercent = 3,
VerticalMarginPercent = 5, VerticalMarginPercent = 5,
Location = ChannelWatermarkLocation.BottomRight, Location = _random.Next() % 2 == 0
? ChannelWatermarkLocation.BottomRight
: ChannelWatermarkLocation.BottomLeft,
Size = ChannelWatermarkSize.Scaled, Size = ChannelWatermarkSize.Scaled,
WidthPercent = 25, WidthPercent = 25,
Opacity = 100 Opacity = 100

Loading…
Cancel
Save