E4: prove dei video fermi e dimostrazione a ogni ora
Completa l'elenco di prove del progetto: analizzatore (grana, luce che pulsa, foto notturna, contenitori, durata sconosciuta, flussi rovinati), servizio (lavori lunghi, file spariti o cambiati, errori, «Interrompi», chiusura), copie del fotogramma (pausa e ripresa, validazione, video sempre intero), API (selezioni, stesso file, eventi) e l'interfaccia vera nel browser: visualizzatore, «Salva il fotogramma», «Cerca i video fermi», Dashboard e filtro «Video fermi». Le prove hanno trovato che la dimostrazione dipendeva dall'ora: la storia ferma poteva avere la copertina del video fermo di marta (un file solo invece di due) e il video «Non analizzabile» poteva mancare. Ora la storia è su un'altra immagine e, se le immagini senza copie non bastano, si usano quelle di foto copiate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eea4394a0f
commit
066addbc84
10 files changed
+1100
-18
No files matched your search
@@ -309,6 +309,98 @@ public sealed class ExportFramesTests
|
||||
Assert.HasCount(6, await bed.ItemsAsync(started.Runs.Single().Id, ct));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task TheFrameOfAStillVideoKeepsItsNameAcrossAPause()
|
||||
{
|
||||
// «Salva il fotogramma» to the folder of the copies (tappa E4, D9): the run says «Fermo», so a job resumed after a
|
||||
// pause (or after Febe closed) names the frame «…_fotogramma» as it would have done, at the instant recorded.
|
||||
var ct = TestContext.CancellationToken;
|
||||
await using var bed = await ExportTestBed.CreateAsync();
|
||||
var video = (await SaveVideoAsync(bed, bed.Marta, "981", Mp4, ".mp4")).Media[0];
|
||||
var usb = await bed.GeneralAsync(ct: ct);
|
||||
var at = TimeSpan.FromMilliseconds(400);
|
||||
await bed.Db.VideoAnalyses.SetAsync(new VideoAnalysis(video.Sha256!, 1, VideoAnalysisOutcome.Still, Make.T0, at), ct);
|
||||
var request = Frames(video, new ExportFramesRequest(FrameMode.Still, null, null, null, ExportFormat.Png));
|
||||
|
||||
bed.Disk.Free = 0;
|
||||
var start = await bed.CopyAsync(request, ct);
|
||||
var run = await bed.RunAsync(start.Runs.Single().Id, ct);
|
||||
Assert.AreEqual(ExportRunState.Paused, run.State, run.LastError);
|
||||
Assert.IsEmpty(Fingerprint.Of(bed.Usb));
|
||||
|
||||
bed.Disk.Free = null;
|
||||
await bed.Service.ResumeAsync([run.Id], ct);
|
||||
await bed.Service.WaitAsync(ct);
|
||||
Assert.AreEqual(ExportRunState.Completed, (await bed.RunAsync(run.Id, ct)).State);
|
||||
var copy = (await bed.Db.Exports.ListCopiesAsync(usb.Id, ct: ct)).Single();
|
||||
Assert.AreEqual("marta.demo/" + Path.ChangeExtension(video.RelativePath!, null) + "_fotogramma.png", copy.RelativePath);
|
||||
Assert.AreEqual((ExportVariant.Frame, ExportFormat.Png), (copy.Variant, copy.Format));
|
||||
Assert.AreEqual(TimeSpan.FromMilliseconds(ExportFrames.ActualMs(Locate(Mp4, [at]).Single().Actual)), copy.FrameAt);
|
||||
Assert.HasCount(1, Fingerprint.Of(bed.Usb));
|
||||
|
||||
// «Questo istante» at the same instant shows the same frame: «Già copiato», not another file.
|
||||
var same = await bed.CopyAsync(Frames(video, new ExportFramesRequest(FrameMode.At, at, null, null, ExportFormat.Png)), ct);
|
||||
var item = (await bed.ItemsAsync(same.Runs.Single().Id, ct)).Single();
|
||||
Assert.AreEqual((ExportItemState.AlreadyCopied, (long?)copy.Id), (item.State, item.CopyId));
|
||||
Assert.HasCount(1, Fingerprint.Of(bed.Usb));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task OnlyAStillVideoGivesItsFrameAndACopyIsAlwaysTheWholeVideo()
|
||||
{
|
||||
var ct = TestContext.CancellationToken;
|
||||
await using var bed = await ExportTestBed.CreateAsync();
|
||||
var video = (await SaveVideoAsync(bed, bed.Marta, "982", Mp4, ".mp4")).Media[0];
|
||||
var other = (await SaveVideoAsync(bed, bed.Marta, "983", TestVideos.Mov(Stream), ".mov")).Media[0];
|
||||
var usb = await bed.GeneralAsync(ct: ct);
|
||||
ExportFramesRequest Still(TimeSpan? at = null, TimeSpan? every = null, int? count = null) => new(FrameMode.Still, at, every, count, ExportFormat.Png);
|
||||
|
||||
// No analysis, «In movimento», «Non analizzabile»: nothing is recorded.
|
||||
foreach (var analysis in new[]
|
||||
{
|
||||
null,
|
||||
new VideoAnalysis(video.Sha256!, 1, VideoAnalysisOutcome.Moving, Make.T0),
|
||||
new VideoAnalysis(video.Sha256!, 1, VideoAnalysisOutcome.NotAnalyzable, Make.T0, null, VideoAnalysisNotes.AllDark),
|
||||
})
|
||||
{
|
||||
if (analysis is not null)
|
||||
{
|
||||
await bed.Db.VideoAnalyses.SetAsync(analysis, ct);
|
||||
}
|
||||
|
||||
var none = await bed.Service.PlanAsync(Frames(video, Still()), ct);
|
||||
Assert.AreEqual((0, 1), (none.Frames, none.NotStill), analysis?.Outcome.ToString());
|
||||
Assert.IsEmpty((await bed.CopyAsync(Frames(video, Still()), ct)).Runs);
|
||||
}
|
||||
|
||||
// One video, nothing but the format (answer 46).
|
||||
await bed.Db.VideoAnalyses.SetAsync(new VideoAnalysis(video.Sha256!, 1, VideoAnalysisOutcome.Still, Make.T0, TimeSpan.Zero), ct);
|
||||
foreach (var wrong in new[]
|
||||
{
|
||||
Frames(video, Still(at: TimeSpan.Zero)),
|
||||
Frames(video, Still(every: TimeSpan.FromSeconds(1))),
|
||||
Frames(video, Still(count: 1)),
|
||||
new ExportJobRequest(new ExportSelection.Media([video.Id, other.Id]), Frames: Still()),
|
||||
new ExportJobRequest(new ExportSelection.Entries([video.EntryId]), Frames: Still()),
|
||||
new ExportJobRequest(new ExportSelection.Account(bed.Marta.Id), Frames: Still()),
|
||||
})
|
||||
{
|
||||
await Assert.ThrowsExactlyAsync<ArgumentException>(() => bed.Service.PlanAsync(wrong, ct));
|
||||
await Assert.ThrowsExactlyAsync<ArgumentException>(() => bed.Service.StartAsync(wrong, ct));
|
||||
}
|
||||
|
||||
Assert.IsEmpty(Fingerprint.Of(bed.Usb));
|
||||
Assert.IsEmpty(await bed.Db.Exports.ListCopiesAsync(usb.Id, ct: ct));
|
||||
|
||||
// «Copia in…» of a still video copies the whole video and nothing else, byte for byte (answer 39).
|
||||
await bed.CopyAccountAsync(bed.Marta, ct: ct);
|
||||
var copies = await bed.Db.Exports.ListCopiesAsync(usb.Id, ct: ct);
|
||||
Assert.HasCount(2, copies);
|
||||
Assert.IsTrue(copies.All(c => c.Variant == ExportVariant.Whole && c.FrameAt is null), string.Join(", ", copies));
|
||||
CollectionAssert.AreEqual(Mp4, await File.ReadAllBytesAsync(bed.GeneralCopy(bed.Marta, video), ct));
|
||||
Assert.HasCount(2, Fingerprint.Of(bed.Usb));
|
||||
}
|
||||
|
||||
/// <summary>A video of one still picture shown for <paramref name="seconds"/>.</summary>
|
||||
private static byte[] LongStill(int seconds)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user