add content_total_seconds to watermark opacity expression (#2275)

This commit is contained in:
Jason Dove
2025-08-07 19:56:56 +00:00
committed by GitHub
parent f2b6f5b919
commit f9db92d5e6
4 changed files with 14 additions and 1 deletions
+1
View File
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- This allows specifying an expression that returns an opacity between 0.0 and 1.0
- The expression can use:
- `content_seconds` - the total number of seconds the frame is into the content
- `content_total_seconds` - the total number of seconds in the content
- `channel_seconds` - the total number of seconds the frame is from when the channel started/activated
- `time_of_day_seconds` - the total number of seconds the frame is since midnight
@@ -12,6 +12,7 @@ public interface IGraphicsElement
object context,
TimeSpan timeOfDay,
TimeSpan contentTime,
TimeSpan contentTotalTime,
TimeSpan channelTime,
CancellationToken cancellationToken);
}
@@ -35,6 +35,9 @@ public class GraphicsEngine(ILogger<GraphicsEngine> logger) : IGraphicsEngine
try
{
// `content_total_seconds` - the total number of seconds in the content
var contentTotalTime = context.Seek + context.Duration;
while (!cancellationToken.IsCancellationRequested && frameCount < totalFrames)
{
// seconds since this specific stream started
@@ -64,7 +67,13 @@ public class GraphicsEngine(ILogger<GraphicsEngine> logger) : IGraphicsEngine
{
if (!element.IsFailed)
{
element.Draw(ctx, frameTime.TimeOfDay, contentTime, channelTime, cancellationToken);
element.Draw(
ctx,
frameTime.TimeOfDay,
contentTime,
contentTotalTime,
channelTime,
cancellationToken);
}
}
catch (Exception ex)
@@ -121,6 +121,7 @@ public class WatermarkElement : IGraphicsElement, IDisposable
object context,
TimeSpan timeOfDay,
TimeSpan contentTime,
TimeSpan contentTotalTime,
TimeSpan channelTime,
CancellationToken cancellationToken)
{
@@ -130,6 +131,7 @@ public class WatermarkElement : IGraphicsElement, IDisposable
}
_expression.Parameters["content_seconds"] = contentTime.TotalSeconds;
_expression.Parameters["content_total_seconds"] = contentTotalTime.TotalSeconds;
_expression.Parameters["channel_seconds"] = channelTime.TotalSeconds;
_expression.Parameters["time_of_day_seconds"] = timeOfDay.TotalSeconds;