Video trash moves across volumes commit once the verified copy has its name and leave an undeletable source whole behind a .leftover marker that the next start settles; deletes rehash under the lease. Restores honour the names renders are writing, and encoders never overwrite an output. Routing floors at the stored settings' format, kindless stills read as stills, star trails restart per loop, and settings the encoder ignored become render warnings. The Videos section fits beside the player, plays downloaded server copies, names blocked videos and says why actions are off; the admin panel offers no download for sequences or missing files and names a filtered sequence from its record. Refs #21 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
2.6 KiB
C#
64 lines
2.6 KiB
C#
using Chronos.Core.Export;
|
|
using Chronos.Core.Imaging;
|
|
using Chronos.Core.Video;
|
|
|
|
namespace Chronos.Core.Tests.Render;
|
|
|
|
/// <summary>One encode recorded by <see cref="CapturingEncoderProvider"/>.</summary>
|
|
internal sealed class CapturedEncode(EncodeSettings settings)
|
|
{
|
|
public EncodeSettings Settings { get; } = settings;
|
|
public List<ImageBuffer> Frames { get; } = [];
|
|
public List<long> Durations { get; } = [];
|
|
public bool Completed { get; set; }
|
|
public bool Disposed { get; set; }
|
|
}
|
|
|
|
/// <summary>Test encoder: keeps a copy of every frame, can pretend to be hardware or to fail at a given frame.</summary>
|
|
internal sealed class CapturingEncoderProvider(string name, params EncoderCapability[] capabilities) : IVideoEncoderProvider
|
|
{
|
|
public string Name => name;
|
|
|
|
public IReadOnlyList<EncoderCapability> Capabilities => capabilities;
|
|
|
|
public List<CapturedEncode> Encodes { get; } = [];
|
|
|
|
/// <summary>When set, WriteFrame throws this for the frame with that zero-based index.</summary>
|
|
public (int Frame, Exception Error)? FailAt { get; set; }
|
|
|
|
/// <summary>The settings each session says it did not take (<see cref="IVideoEncoderSession.Ignored"/>).</summary>
|
|
public IReadOnlyList<EncoderSetting> Ignores { get; set; } = [];
|
|
|
|
public bool CanEncode(EncodeSettings settings) => capabilities.Any(c =>
|
|
c.Codec == settings.Codec && EncoderSelector.Takes(c, settings.Width, settings.Height) && (settings.BitDepth == 8 || c.SupportsTenBit));
|
|
|
|
public IVideoEncoderSession Open(EncodeSettings settings)
|
|
{
|
|
var encode = new CapturedEncode(settings);
|
|
Encodes.Add(encode);
|
|
var capability = capabilities.First(c => c.Codec == settings.Codec);
|
|
return new Session(this, encode, capability);
|
|
}
|
|
|
|
private sealed class Session(CapturingEncoderProvider owner, CapturedEncode encode, EncoderCapability capability) : IVideoEncoderSession
|
|
{
|
|
public string EncoderName => capability.Name;
|
|
|
|
public bool IsHardware => capability.Hardware;
|
|
|
|
public void WriteFrame(ImageBuffer frame, long duration90k)
|
|
{
|
|
if (owner.FailAt is { } fail && fail.Frame == encode.Frames.Count) throw fail.Error;
|
|
if (frame.Width != encode.Settings.Width || frame.Height != encode.Settings.Height) throw new ArgumentException("size");
|
|
encode.Frames.Add(frame.Clone());
|
|
encode.Durations.Add(duration90k);
|
|
}
|
|
|
|
public void Complete() => encode.Completed = true;
|
|
|
|
public void Dispose() => encode.Disposed = true;
|
|
|
|
public IReadOnlyList<EncoderSetting> Ignored => owner.Ignores;
|
|
}
|
|
}
|