add nth frame to ai recognition to config

This commit is contained in:
Alex Bezdieniezhnykh
2024-12-03 11:36:20 +02:00
parent 0b38d9b24c
commit 3944df8efe
12 changed files with 81 additions and 29 deletions
@@ -2,12 +2,13 @@
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Azaion.Common.DTO.Config;
using LibVLCSharp.Shared;
using SkiaSharp;
namespace Azaion.Annotator.Extensions;
public class VLCFrameExtractor(LibVLC libVLC)
public class VLCFrameExtractor(LibVLC libVLC, AIRecognitionConfig config)
{
private const uint RGBA_BYTES = 4;
private const int PLAYBACK_RATE = 4;
@@ -104,10 +105,11 @@ public class VLCFrameExtractor(LibVLC libVLC)
_lastFrameTimestamp = playerTime;
}
if (_frameCounter > 20 && _frameCounter % 10 == 0)
if (_frameCounter > 20 && _frameCounter % config.FramePeriodRecognition == 0)
{
var msToAdd = (_frameCounter - _lastFrame) * (_lastFrame == 0 ? 0 : _lastFrameTimestamp.TotalMilliseconds / _lastFrame);
var time = _lastFrameTimestamp.Add(TimeSpan.FromMilliseconds(msToAdd));
FramesQueue.Enqueue(new FrameInfo(time, _currentBitmap));
}
else