feat: export panel and Render menu, playback options, videos library (owner review 1 phase 5) (#27)
CI / Build and test (push) Successful in 9m41s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 9s
Release / Build, test and publish (push) Successful in 14m49s
CI / PostgreSQL 16 integration (push) Successful in 8m51s
CI / PostgreSQL 17 integration (push) Successful in 9m48s
CI / Docker image (push) Successful in 54s
Release / Server image (push) Successful in 1m39s
CI / Build and test (push) Successful in 9m41s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 9s
Release / Build, test and publish (push) Successful in 14m49s
CI / PostgreSQL 16 integration (push) Successful in 8m51s
CI / PostgreSQL 17 integration (push) Successful in 9m48s
CI / Docker image (push) Successful in 54s
Release / Server image (push) Successful in 1m39s
Owner review 1 R3, R8, R9. A grouped Export step and Render menu; encoding, playback (reverse, boomerang, loops, fades, hold) and still frames; one videos library on the desktop and the server with a verified trash and copies to a videos folder. Closes #21 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #27.
This commit is contained in:
1 parent
188b2c2e55
commit
728ffa35cb
729 files changed
+26954
-1652
No files matched your search
@@ -33,6 +33,7 @@ public sealed class MediaFoundationEncoderSession : IVideoEncoderSession
|
||||
private readonly Dictionary<long, long> _ticksByHns = [];
|
||||
private readonly Dictionary<long, long> _durationByTicks = [];
|
||||
private readonly Queue<long> _inputStarts = new();
|
||||
private readonly List<EncoderSetting> _ignored = [];
|
||||
private bool _providesSamples;
|
||||
private uint _outputBufferSize;
|
||||
private int _needInput;
|
||||
@@ -58,6 +59,7 @@ public sealed class MediaFoundationEncoderSession : IVideoEncoderSession
|
||||
if (UnlockAsync(transform))
|
||||
_events = transform as IMFMediaEventGenerator ?? throw new NotSupportedException("Asynchronous MFT without an event generator");
|
||||
if (transform as ICodecAPI is { } codecApi) ApplyCodecSettings(codecApi);
|
||||
else _ignored.AddRange(Asked());
|
||||
SetOutputType();
|
||||
SetInputType();
|
||||
ReadOutputStreamInfo();
|
||||
@@ -157,7 +159,8 @@ public sealed class MediaFoundationEncoderSession : IVideoEncoderSession
|
||||
_muxer.Complete();
|
||||
_file.Flush(flushToDisk: true);
|
||||
_file.Dispose();
|
||||
AtomicFile.Commit(_tempPath, _settings.OutputPath);
|
||||
// The render picked a free name: something that took it meanwhile (a restore) is never overwritten.
|
||||
AtomicFile.CommitNew(_tempPath, _settings.OutputPath);
|
||||
_completed = true;
|
||||
Log.Info(LogCategory, $"\"{EncoderName}\" encoded {_framesIn} frames into {_framesOut} samples: {_settings.OutputPath}");
|
||||
}
|
||||
@@ -208,27 +211,51 @@ public sealed class MediaFoundationEncoderSession : IVideoEncoderSession
|
||||
RateControl.Quality => MfNative.RateControlQuality,
|
||||
_ => MfNative.RateControlUnconstrainedVbr,
|
||||
};
|
||||
SetCodecValue(api, MfGuids.CodecRateControlMode, ComVariant.Create(mode), "RateControlMode");
|
||||
var asked = Asked().ToHashSet();
|
||||
void Set(in Guid property, ComVariant value, string name, EncoderSetting setting)
|
||||
{
|
||||
if (!SetCodecValue(api, property, value, name) && asked.Contains(setting) && !_ignored.Contains(setting)) _ignored.Add(setting);
|
||||
}
|
||||
|
||||
Set(MfGuids.CodecRateControlMode, ComVariant.Create(mode), "RateControlMode", EncoderSetting.RateControl);
|
||||
if (_settings.RateControl == RateControl.Quality)
|
||||
SetCodecValue(api, MfGuids.CodecQuality, ComVariant.Create((uint)Math.Clamp(_settings.Quality, 1, 100)), "Quality");
|
||||
Set(MfGuids.CodecQuality, ComVariant.Create((uint)Math.Clamp(_settings.Quality, 1, 100)), "Quality", EncoderSetting.Quality);
|
||||
else
|
||||
SetCodecValue(api, MfGuids.CodecMeanBitRate, ComVariant.Create(BitRate), "MeanBitRate");
|
||||
Set(MfGuids.CodecMeanBitRate, ComVariant.Create(BitRate), "MeanBitRate", EncoderSetting.BitRate);
|
||||
var gop = _settings.GopLength > 0 ? _settings.GopLength : (int)Math.Max(1, Math.Round(_settings.FrameRate.Value));
|
||||
SetCodecValue(api, MfGuids.CodecGopSize, ComVariant.Create((uint)gop), "GOPSize");
|
||||
Set(MfGuids.CodecGopSize, ComVariant.Create((uint)gop), "GOPSize", EncoderSetting.KeyframeInterval);
|
||||
var bFrames = _settings.Profile == CodecProfile.H264Baseline ? 0 : Math.Max(0, _settings.BFrames);
|
||||
SetCodecValue(api, MfGuids.CodecBPictureCount, ComVariant.Create((uint)bFrames), "BPictureCount");
|
||||
Set(MfGuids.CodecBPictureCount, ComVariant.Create((uint)bFrames), "BPictureCount", EncoderSetting.BFrames);
|
||||
SetCodecValue(api, MfGuids.CodecLowLatencyMode, ComVariant.Create(false), "LowLatencyMode");
|
||||
}
|
||||
|
||||
private static unsafe void SetCodecValue(ICodecAPI api, in Guid property, ComVariant value, string name)
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyList<EncoderSetting> Ignored => _ignored;
|
||||
|
||||
/// <summary>
|
||||
/// The settings that name a value of their own rather than the encoder's default, whose refusal the render reports: a rate
|
||||
/// control other than VBR, its quality, a bit rate given, a keyframe interval given, a B-frame count other than the default.
|
||||
/// </summary>
|
||||
private IEnumerable<EncoderSetting> Asked()
|
||||
{
|
||||
if (_settings.RateControl != RateControl.Vbr) yield return EncoderSetting.RateControl;
|
||||
if (_settings.RateControl == RateControl.Quality) yield return EncoderSetting.Quality;
|
||||
else if (_settings.BitRate > 0) yield return EncoderSetting.BitRate;
|
||||
if (_settings.GopLength > 0) yield return EncoderSetting.KeyframeInterval;
|
||||
if (_settings.Profile != CodecProfile.H264Baseline && _settings.BFrames != EncodeSettings.DefaultBFrames) yield return EncoderSetting.BFrames;
|
||||
}
|
||||
|
||||
/// <summary>Sets an ICodecAPI property; false (logged) when the encoder does not support it or refuses the value.</summary>
|
||||
private static unsafe bool SetCodecValue(ICodecAPI api, in Guid property, ComVariant value, string name)
|
||||
{
|
||||
if (api.IsSupported(property) != 0)
|
||||
{
|
||||
Log.Debug(LogCategory, $"ICodecAPI {name} not supported by the encoder");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
var hr = api.SetValue(property, (nint)(&value));
|
||||
if (hr < 0) Log.Debug(LogCategory, $"ICodecAPI {name} rejected (0x{hr:X8})");
|
||||
return hr >= 0;
|
||||
}
|
||||
|
||||
/// <summary>Requested bit rate, or the preset density (§11.4: 0.10/0.07/0.05 bits per pixel per frame) when unset.</summary>
|
||||
|
||||
Reference in new issue
Block a user