private static IEnumerable<FrameFingerPrintWrapper> IndexVideo( string videoFile, MediaInfo info, long maxMemory ) { TimeSpan totalDuration = info.GetDuration(); var ffmpegProcessSettings = new FFMPEGProcessVideoSettings( videoFile, info.GetFramerate().Numerator, info.GetFramerate().Denominator * 4, FFMPEGMode.PlaybackAtFourX ); using (var indexingPool = new VideoIndexingExecutor(4, (long)Math.Round((3.0 * maxMemory) / 4.0))) using (var byteStore = new RawByteStore(info.GetWidth(), info.GetHeight(), indexingPool, (long)Math.Round(maxMemory / 4.0))) using (var ffmpegProcess = new FFMPEGProcess(ffmpegProcessSettings, (byteArray, bytesToSubmit) => { byteStore.Submit(byteArray, bytesToSubmit); })) { ffmpegProcess.Execute(); byteStore.Shutdown(); byteStore.Wait(); indexingPool.Shutdown(); indexingPool.Wait(); return indexingPool.GetFingerPrints(); } }
public RawByteStore(int width, int height, VideoIndexingExecutor videoIndexer, long maxCapacity) { _disposed = false; _currentMemoryLevel = 0; _width = width; _height = height; _rawByteQueue = new BlockingCollection <byte[]>(); _videoIndexer = videoIndexer; _queueTask = Task.Factory.StartNew(RunQueue); _maxCapacity = maxCapacity; _capacityBarrier = new ManualResetEventSlim(true); }