feat(pipeline): render-derived shot thumbnails, and bulk shot delete
Deploy / deploy (push) Failing after 19m11s
Deploy / deploy (push) Failing after 19m11s
Two independent features landing together: Generated shot thumbnails — a shot can now carry a thumbnail promoted from a render export (Shot.generatedThumbnailUrl/generatedThumbnailFrom) alongside the existing brief-supplied thumbnailUrl, which always takes display precedence (lib/shot-thumbnail.ts) so a promoted frame can only ever fill a gap, never overwrite the brief. Shows with pipelineConfig.autoShotThumbnail promote automatically on every finished export (lib/render-pipeline/preview.ts); promoteExportThumbnail/ clearGeneratedThumbnail (actions/shots.ts) are the manual equivalent for everyone else. Worker-side seek logic for picking the promoted frame is covered by RenderWorker/VFXReviewWorker.Tests/ThumbnailSeekTests.cs. Bulk shot delete — the shot-status page's selection bar gets a "Bulk Actions" dropdown (alongside the existing Change Due Date) with Delete Shots. bulkDeleteShots() (actions/shots.ts) deletes one at a time rather than in a single statement: exports_shotId_fkey is ON DELETE RESTRICT by design, so a shot with renders or deliveries on record is protected and gets skipped and reported by name rather than aborting the whole selection or being silently destroyed along with its history. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using VFXReviewWorker;
|
||||
using Xunit;
|
||||
|
||||
namespace VFXReviewWorker.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// The preview MP4 opens on the Netflix slate. ffmpeg's <c>thumbnail</c> filter
|
||||
/// only considers the first 100 frames, so every thumbnail the pipeline has ever
|
||||
/// produced was a picture of the slate card rather than of the shot — invisible
|
||||
/// while thumbnails were only decoration in the QC queue, and unacceptable now
|
||||
/// they can become a shot's thumbnail.
|
||||
///
|
||||
/// The fix is to seek past the slate, so the seek arithmetic is worth pinning.
|
||||
/// </summary>
|
||||
public class ThumbnailSeekTests
|
||||
{
|
||||
private static PreviewBuildResult Build(double? pictureStart, int? frameCount) =>
|
||||
new() { PictureStartSeconds = pictureStart, FrameCount = frameCount };
|
||||
|
||||
[Fact]
|
||||
public void SeeksAQuarterIntoPictureNotIntoTheFile()
|
||||
{
|
||||
// 5s slate, then 96 frames (4s) of picture at 24fps → 5 + 1 = 6s.
|
||||
var seek = PreviewStage.ThumbnailSeekSeconds(Build(5.0, 96), 24);
|
||||
Assert.NotNull(seek);
|
||||
Assert.Equal(6.0, seek!.Value, 3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HandlesATemplateWithNoSlateAtAll()
|
||||
{
|
||||
var seek = PreviewStage.ThumbnailSeekSeconds(Build(0.0, 240), 24);
|
||||
Assert.Equal(2.5, seek!.Value, 3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FallsBackWhenTheBuildDidNotReportWherePictureStarts()
|
||||
{
|
||||
// Older worker, or a template with no SHOT layer: null means "keep the
|
||||
// old whole-file behaviour" rather than guessing an offset.
|
||||
Assert.Null(PreviewStage.ThumbnailSeekSeconds(Build(null, 96), 24));
|
||||
Assert.Null(PreviewStage.ThumbnailSeekSeconds(null, 24));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(-1.0, 96, 24)] // negative slate length
|
||||
[InlineData(5.0, 0, 24)] // no picture frames
|
||||
[InlineData(5.0, -5, 24)] // nonsense frame count
|
||||
[InlineData(5.0, 96, 0)] // no fps to divide by
|
||||
public void RefusesNumbersThatDoNotDescribeARealClip(double start, int frames, double fps)
|
||||
{
|
||||
Assert.Null(PreviewStage.ThumbnailSeekSeconds(Build(start, frames), fps));
|
||||
}
|
||||
}
|
||||
@@ -193,6 +193,12 @@ public sealed class PreviewBuildResult
|
||||
public int? FrameCount { get; set; }
|
||||
public int? Width { get; set; }
|
||||
public int? Height { get; set; }
|
||||
/// <summary>
|
||||
/// Seconds of slate ahead of picture in the preview comp (the SHOT layer's
|
||||
/// in-point). Null on builds predating this field, or when the template has
|
||||
/// no SHOT layer — the thumbnail then falls back to scanning from frame 0.
|
||||
/// </summary>
|
||||
public double? PictureStartSeconds { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>The Render Manifest (§6.2) — the fields the render and validation stages need; the rest is preserved raw.</summary>
|
||||
|
||||
@@ -179,7 +179,7 @@ public sealed class PreviewStage
|
||||
null, null, null, build.TempAep, build, sw.Elapsed.TotalSeconds);
|
||||
}
|
||||
|
||||
var thumbnail = await TryMakeThumbnailAsync(job.Id, mp4Local, shutdown);
|
||||
var thumbnail = await TryMakeThumbnailAsync(job.Id, mp4Local, build, manifest.Fps, shutdown);
|
||||
|
||||
sw.Stop();
|
||||
_log.LogInformation("Preview complete for job {JobId} in {Sec:F0}s (mov + mp4{Thumb})",
|
||||
@@ -231,8 +231,24 @@ public sealed class PreviewStage
|
||||
return process.ExitCode;
|
||||
}
|
||||
|
||||
/// <summary>Optional 960-wide poster frame at 25% duration (§9.1). Never fatal.</summary>
|
||||
private async Task<string?> TryMakeThumbnailAsync(string jobId, string mp4Path, CancellationToken ct)
|
||||
/// <summary>
|
||||
/// Optional 960-wide poster frame at 25% of <em>picture</em> duration
|
||||
/// (§9.1). Never fatal.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The preview MP4 opens on the Netflix slate, so the frame has to be taken
|
||||
/// relative to picture rather than to the file. This previously used
|
||||
/// ffmpeg's <c>thumbnail</c> filter, which considers only the first 100
|
||||
/// frames — on a slated preview that is the slate card, which is what every
|
||||
/// thumbnail in the system was until now. Seeking to
|
||||
/// <c>pictureStart + 25%</c> matches what §9.1 always documented and is what
|
||||
/// makes these frames usable as shot thumbnails.
|
||||
///
|
||||
/// A build that reports no picture start (older worker, or a template with
|
||||
/// no SHOT layer) keeps the old whole-file behaviour rather than guessing.
|
||||
/// </remarks>
|
||||
private async Task<string?> TryMakeThumbnailAsync(
|
||||
string jobId, string mp4Path, PreviewBuildResult? build, double fps, CancellationToken ct)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_options.FfmpegPath) || !File.Exists(_options.FfmpegPath))
|
||||
{
|
||||
@@ -249,7 +265,32 @@ public sealed class PreviewStage
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
};
|
||||
foreach (var a in new[] { "-y", "-i", mp4Path, "-vf", "thumbnail,scale=960:-1", "-frames:v", "1", outPath })
|
||||
|
||||
var args = new List<string> { "-y" };
|
||||
var seek = ThumbnailSeekSeconds(build, fps);
|
||||
if (seek is { } t)
|
||||
{
|
||||
// Before -i: ffmpeg seeks by keyframe, which is fast and accurate
|
||||
// enough for a poster frame.
|
||||
args.Add("-ss");
|
||||
args.Add(t.ToString("0.###", System.Globalization.CultureInfo.InvariantCulture));
|
||||
args.Add("-i");
|
||||
args.Add(mp4Path);
|
||||
args.Add("-vf");
|
||||
args.Add("scale=960:-1");
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Add("-i");
|
||||
args.Add(mp4Path);
|
||||
args.Add("-vf");
|
||||
args.Add("thumbnail,scale=960:-1");
|
||||
}
|
||||
args.Add("-frames:v");
|
||||
args.Add("1");
|
||||
args.Add(outPath);
|
||||
|
||||
foreach (var a in args)
|
||||
{
|
||||
psi.ArgumentList.Add(a);
|
||||
}
|
||||
@@ -270,6 +311,19 @@ public sealed class PreviewStage
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Timestamp for the poster frame: a quarter of the way into picture,
|
||||
/// skipping the slate. Null when the build did not report where picture
|
||||
/// starts, or when the numbers do not describe a real clip.
|
||||
/// </summary>
|
||||
internal static double? ThumbnailSeekSeconds(PreviewBuildResult? build, double fps)
|
||||
{
|
||||
if (build?.PictureStartSeconds is not { } start || start < 0) return null;
|
||||
if (build.FrameCount is not { } frames || frames <= 0) return null;
|
||||
if (fps <= 0) return null;
|
||||
return start + (frames / fps) * 0.25;
|
||||
}
|
||||
|
||||
private static PreviewStageResult Fail(string message, bool retryable, Stopwatch sw, PreviewBuildResult? build = null)
|
||||
{
|
||||
sw.Stop();
|
||||
|
||||
@@ -30,7 +30,11 @@
|
||||
queued: [],
|
||||
frameCount: null,
|
||||
width: null,
|
||||
height: null
|
||||
height: null,
|
||||
// Seconds of slate ahead of picture in the preview comp — the SHOT
|
||||
// layer's in-point. The worker needs it to grab a thumbnail from
|
||||
// picture rather than from the slate card.
|
||||
pictureStartSeconds: null
|
||||
};
|
||||
var resultPath = null;
|
||||
|
||||
@@ -512,6 +516,8 @@
|
||||
|
||||
var shotLayer = previewComp.layer("SHOT");
|
||||
var targetOutPoint = shotLayer.inPoint + shotComp.duration;
|
||||
// Everything before this is slate; the thumbnail has to start after it.
|
||||
result.pictureStartSeconds = shotLayer.inPoint;
|
||||
if (targetOutPoint > previewComp.duration) {
|
||||
previewComp.duration = targetOutPoint;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user