E4: video_analysis con istante del fotogramma e nota (migrazione 0005)

«Salva il fotogramma» deve salvare il fotogramma scelto dall'analisi (il
più nitido, mai uno nero) e il visualizzatore deve dire perché un video è
«Non analizzabile». La migrazione 0005 aggiunge a video_analysis
frame_at_ms e note, con i CHECK nello schema: un «Fermo» ha sempre il suo
istante e nessun altro esito ne ha uno, un «Non analizzabile» ha sempre la
nota. Un indice parziale sugli esiti fermi serve al filtro «Video fermi».
Le righe impossibili (scritte a mano: nessun Febe prima di E4 scrive la
tabella) si tolgono prima, così la migrazione non si ferma.

VideoAnalysis ha FrameAt e Note; VideoAnalysisNotes elenca i codici,
compreso SingleColor per il video tutto di un colore (risposta 42 di
Alberto: tutto nero o di un colore è «Non analizzabile»). L'archivio
legge e scrive le colonne nuove e rifiuta le forme che lo schema rifiuta,
e una nota che non sia fatta di codici.

Prove: versione dello schema 5, aggiornamento dalla 4, la 0005 cambia
solo video_analysis, vincoli e archivio.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-29 13:54:30 +01:00
1 parent b3c15da821
commit 0cd842a518
8 files changed
+278 -20

No files matched your search

+41 -2
View File
@@ -343,8 +343,47 @@ public sealed record ExportItem
public string? LastError { get; init; }
}
/// <summary>Outcome of the still-video analysis of one algorithm for one SHA-256 (spec §8.3 <c>video_analysis</c>).</summary>
public sealed record VideoAnalysis(string Sha256, int Algorithm, VideoAnalysisOutcome Outcome, DateTimeOffset AnalyzedAt);
/// <summary>
/// Outcome of the still-video analysis of one algorithm for one SHA-256 (spec §8.3 <c>video_analysis</c>, migration
/// 0005 of tappa E4). <paramref name="FrameAt"/> is the shown instant of the frame «Salva il fotogramma» saves: set for
/// <see cref="VideoAnalysisOutcome.Still"/> and only for it. <paramref name="Note"/> says why, as codes of
/// <see cref="VideoAnalysisNotes"/> separated by spaces: always set for <see cref="VideoAnalysisOutcome.NotAnalyzable"/>.
/// </summary>
public sealed record VideoAnalysis(
string Sha256,
int Algorithm,
VideoAnalysisOutcome Outcome,
DateTimeOffset AnalyzedAt,
TimeSpan? FrameAt = null,
string? Note = null);
/// <summary>
/// The codes of <c>video_analysis.note</c> (tappa E4), English, separated by spaces like <c>export_item.note</c>. They
/// say why a video is «Non analizzabile».
/// </summary>
public static class VideoAnalysisNotes
{
/// <summary>The video has no frames Febe can decode (codec, profile or container outside spec §3, damaged headers).</summary>
public const string FrameNotAvailable = "FrameNotAvailable";
/// <summary>The video has more than one frame and no known duration.</summary>
public const string DurationUnknown = "DurationUnknown";
/// <summary>The frames of the video cannot be read (a damaged or truncated file).</summary>
public const string Unreadable = "Unreadable";
/// <summary>The analysis took longer than its time limit (only an analysis from a selection stores it).</summary>
public const string TooSlow = "TooSlow";
/// <summary>Every frame looked at is black or nearly black (answer 42 of Alberto, 29 November 2026).</summary>
public const string AllDark = "AllDark";
/// <summary>Every frame looked at is all of one single colour, not dark (answer 42 of Alberto, 29 November 2026).</summary>
public const string SingleColor = "SingleColor";
/// <summary>Every code of algorithm 1, in the order above.</summary>
public static IReadOnlyList<string> All { get; } = [FrameNotAvailable, DurationUnknown, Unreadable, TooSlow, AllDark, SingleColor];
}
/// <summary>
/// A converted file added to an entry by the conversion for the library (spec §4.10, §8.3 <c>media_conversion</c>),
+8 -2
View File
@@ -4,7 +4,8 @@ namespace Febe.Core.Storage;
/// <summary>
/// Outcomes of «È un video fermo?» by SHA-256 of the video and number of the algorithm (spec §4.10, §8.3
/// <c>video_analysis</c>). No link to the library: an outcome outlives deletion and re-import of the same file.
/// <c>video_analysis</c>, columns <c>frame_at_ms</c> and <c>note</c> from migration 0005). No link to the library: an
/// outcome outlives deletion and re-import of the same file.
/// </summary>
public interface IVideoAnalysisStore
{
@@ -14,6 +15,11 @@ public interface IVideoAnalysisStore
/// <summary>The analysis with the highest algorithm number for each SHA-256 that has one, keyed by lower-case SHA-256.</summary>
Task<IReadOnlyDictionary<string, VideoAnalysis>> GetManyAsync(IReadOnlyCollection<string> sha256s, CancellationToken ct = default);
/// <summary>Stores (or replaces) the outcome of one algorithm for one SHA-256.</summary>
/// <summary>
/// Stores (or replaces) the outcome of one algorithm for one SHA-256, with the instant of its frame and its note.
/// Throws <see cref="ArgumentException"/> for a still video without an instant (or before the start), an instant on
/// another outcome, a note that is not codes separated by spaces, or a «Non analizzabile» without a note. The instant
/// is kept in whole milliseconds.
/// </summary>
Task SetAsync(VideoAnalysis analysis, CancellationToken ct = default);
}