E4: API dei video fermi e «Salva il fotogramma»
«È un video fermo?» dal visualizzatore (POST /api/media/{id}/still, con
400/404/409/503 e niente salvato negli errori) e l'esito su ogni video
dell'elemento (media[].still), perché l'interfaccia di WP6 lo mostri.
«Salva il fotogramma» salva il fotogramma scelto dall'analisi (il più
nitido, mai uno scuro, risposta 45): «Scarica» da
/api/media/{id}/still/frame con il nome …_fotogramma.png, e «Nella
cartella delle copie» con frames.mode "fermo" attraverso pianificatore,
impostazioni del lavoro e copiatore (FrameMode.Still, suffisso
_fotogramma, stessa identità delle copie dei fotogrammi di E3). Vale per
un video solo (risposta 46); un video non fermo o mai analizzato si
conta come notStill e non si copia.
«Cerca i video fermi» per una selezione: conferma con i conteggi,
avvio, avanzamento e «Interrompi» (/api/still-videos/*). Tutti i DTO nel
FebeJsonContext; i comandi passano dal controllo dell'Origin. Il servizio
registra con ILogger e FebeApp lo chiude all'arresto prima dell'archivio.
LEGGIMI di Febe.Web aggiornato; prove dell'API su video costruiti.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4f238f2c9f
commit
51150fb611
17 files changed
+695
-18
No files matched your search
@@ -99,7 +99,12 @@ public sealed class ExportPlanner(ExportEnvironment env)
|
||||
throw new ArgumentException("L'intervallo minimo è 0,1 secondi.", nameof(request));
|
||||
case FrameMode.Count when frames.Count is not ({ } count and >= 1 and <= ExportFrames.MaxCount):
|
||||
throw new ArgumentException("Da 1 a 1.000 fotogrammi.", nameof(request));
|
||||
case FrameMode.At or FrameMode.Every or FrameMode.Count:
|
||||
case FrameMode.Still when frames.At is not null || frames.Every is not null || frames.Count is not null:
|
||||
throw new ArgumentException("«Salva il fotogramma» prende il fotogramma scelto dall'analisi: niente istante, intervallo o numero.", nameof(request));
|
||||
case FrameMode.Still when request.Selection is not ExportSelection.Media { MediaIds.Count: 1 }:
|
||||
// Answer 46 of Alberto (29 November 2026): only from the viewer, one video.
|
||||
throw new ArgumentException("«Salva il fotogramma» vale per un video solo, dal visualizzatore.", nameof(request));
|
||||
case FrameMode.At or FrameMode.Every or FrameMode.Count or FrameMode.Still:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("Modo dei fotogrammi sconosciuto.", nameof(request));
|
||||
@@ -294,6 +299,24 @@ public sealed class ExportPlanner(ExportEnvironment env)
|
||||
Prediction = ExportPrediction.Converted,
|
||||
FirstOfVideo = true,
|
||||
};
|
||||
if (frames.Mode == FrameMode.Still)
|
||||
{
|
||||
// «Salva il fotogramma» (tappa E4): the instant the analysis chose, by SHA-256 of the file; a video
|
||||
// that is not «Fermo» (or was never analysed) gives nothing.
|
||||
var analysis = await _env.Storage.VideoAnalyses.GetAsync(c.Sha256!, ct).ConfigureAwait(false);
|
||||
if (analysis is not { Outcome: VideoAnalysisOutcome.Still, FrameAt: { } still })
|
||||
{
|
||||
yield return frame with { Action = PlannedCopy.NotStill };
|
||||
continue;
|
||||
}
|
||||
|
||||
var chosen = frame with { FrameAt = still };
|
||||
yield return seen.Add((destination, c.AccountId, c.Sha256!, (long)still.TotalMilliseconds, frames.Format))
|
||||
? chosen
|
||||
: chosen with { Action = PlannedCopy.AlreadyCopied };
|
||||
continue;
|
||||
}
|
||||
|
||||
var duration = c.Duration ?? TimeSpan.Zero;
|
||||
if (frames.Mode != FrameMode.At && c.Duration is null)
|
||||
{
|
||||
@@ -409,6 +432,9 @@ internal enum PlannedCopy
|
||||
|
||||
/// <summary>Frames job: a video over <see cref="ExportFrames.MaxPerVideo"/> frames.</summary>
|
||||
OverCap,
|
||||
|
||||
/// <summary>«Salva il fotogramma» (tappa E4): a video whose analysis is not «Fermo», or that was never analysed.</summary>
|
||||
NotStill,
|
||||
}
|
||||
|
||||
/// <summary>Counts of a plan while its files go by.</summary>
|
||||
@@ -441,15 +467,20 @@ internal sealed class PlanTally
|
||||
|
||||
public int OverCap { get; private set; }
|
||||
|
||||
public int NotStill { get; private set; }
|
||||
|
||||
public void Add(PlannedFile file)
|
||||
{
|
||||
if (file.FirstOfVideo && file.Action is not (PlannedCopy.OverCap or PlannedCopy.NotExported or PlannedCopy.Missing))
|
||||
if (file.FirstOfVideo && file.Action is not (PlannedCopy.OverCap or PlannedCopy.NotExported or PlannedCopy.Missing or PlannedCopy.NotStill))
|
||||
{
|
||||
Videos++;
|
||||
}
|
||||
|
||||
switch (file.Action)
|
||||
{
|
||||
case PlannedCopy.NotStill:
|
||||
NotStill++;
|
||||
return;
|
||||
case PlannedCopy.Missing:
|
||||
Missing++;
|
||||
return;
|
||||
@@ -545,6 +576,7 @@ internal sealed class PlanTally
|
||||
PhotosSkipped = PhotosSkipped,
|
||||
Frames = Frames,
|
||||
OverCap = OverCap,
|
||||
NotStill = NotStill,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user