Browse Source

song improvements (#508)

* fix song details margin and use dynamic font size

* sometimes use cover art color for song background
pull/509/head
Jason Dove 5 years ago committed by GitHub
parent
commit
015232fad6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CHANGELOG.md
  2. 23
      ErsatzTV.Core/FFmpeg/FFmpegComplexFilterBuilder.cs

2
CHANGELOG.md

@ -11,6 +11,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed ### Changed
- Randomly place song cover art on left or right side of screen - Randomly place song cover art on left or right side of screen
- Randomly use a solid color from the cover art instead of blurred cover art for song background
- Use dynamic font size (based on resolution) for song details
## [0.3.0-alpha] - 2021-11-25 ## [0.3.0-alpha] - 2021-11-25
### Fixed ### Fixed

23
ErsatzTV.Core/FFmpeg/FFmpegComplexFilterBuilder.cs

@ -14,6 +14,8 @@ namespace ErsatzTV.Core.FFmpeg
{ {
public class FFmpegComplexFilterBuilder public class FFmpegComplexFilterBuilder
{ {
private static readonly Random Random = new();
private Option<TimeSpan> _audioDuration = None; private Option<TimeSpan> _audioDuration = None;
private bool _deinterlace; private bool _deinterlace;
private Option<HardwareAccelerationKind> _hardwareAccelerationKind = None; private Option<HardwareAccelerationKind> _hardwareAccelerationKind = None;
@ -119,7 +121,7 @@ namespace ErsatzTV.Core.FFmpeg
} }
var horizontalMarginPercent = 3; var horizontalMarginPercent = 3;
const int VERTICAL_MARGIN_PERCENT = 14; const int VERTICAL_MARGIN_PERCENT = 5;
foreach (ChannelWatermark watermark in _watermark) foreach (ChannelWatermark watermark in _watermark)
{ {
@ -135,10 +137,10 @@ namespace ErsatzTV.Core.FFmpeg
double horizontalMargin = Math.Round(horizontalMarginPercent / 100.0 * _resolution.Width); double horizontalMargin = Math.Round(horizontalMarginPercent / 100.0 * _resolution.Width);
double verticalMargin = Math.Round(VERTICAL_MARGIN_PERCENT / 100.0 * _resolution.Height); double verticalMargin = Math.Round(VERTICAL_MARGIN_PERCENT / 100.0 * _resolution.Height);
var location = $"x={horizontalMargin}:y=H-{verticalMargin}"; var location = $"x={horizontalMargin}:y=H-text_h-{verticalMargin}";
_drawtext = _drawtext =
$"drawtext=fontfile={fontPath}:textfile={effectiveFile}:{location}:fontsize=36:fontcolor=white"; $"drawtext=fontfile={fontPath}:textfile={effectiveFile}:{location}:fontsize=(h/25):fontcolor=white";
} }
} }
@ -296,7 +298,20 @@ namespace ErsatzTV.Core.FFmpeg
if (videoOnly) if (videoOnly)
{ {
videoFilterQueue.Add("boxblur=40[b];[b]split[b1][b2];[b1]format=rgba,geq=r=0:g=0:b=0:a=120*(Y/H)[fg];[b2][fg]overlay=format=auto"); var filter = "boxblur=40";
int next = Random.Next() % 16;
if (next < 8)
{
videoFilterQueue.RemoveAll(s => s.Contains("scale="));
filter =
$"palettegen=max_colors=8,crop=1:1:{next}:0,scale={_resolution.Width}:{_resolution.Height},setsar=1:1";
}
filter +=
"[b];[b]split[b1][b2];[b1]format=rgba,geq=r=0:g=0:b=0:a=120*(Y/H)[fg];[b2][fg]overlay=format=auto";
videoFilterQueue.Add(filter);
} }
if (isSong) if (isSong)

Loading…
Cancel
Save