public static async Task <int> GetInputFrameCountAsync(string path) { long filesize = IOUtils.GetFilesize(path); PseudoUniqueFile hash = new PseudoUniqueFile(path, filesize); if (filesize > 0 && FrameCountCacheContains(hash)) { Logger.Log($"FrameCountCache contains this hash, using cached frame count.", true); return(GetFrameCountFromCache(hash)); } else { Logger.Log($"Hash not cached, reading frame count.", true); } int frameCount; if (IOUtils.IsPathDirectory(path)) { frameCount = IOUtils.GetAmountOfFiles(path, false); } else { frameCount = await FfmpegCommands.GetFrameCountAsync(path); } Logger.Log($"Adding hash with frame count {frameCount} to cache.", true); frameCountCache.Add(hash, frameCount); return(frameCount); }
private static int GetFrameCountFromCache(PseudoUniqueFile hash) { foreach (KeyValuePair <PseudoUniqueFile, int> entry in frameCountCache) { if (entry.Key.path == hash.path && entry.Key.filesize == hash.filesize) { return(entry.Value); } } return(0); }
private static bool FrameCountCacheContains(PseudoUniqueFile hash) { foreach (KeyValuePair <PseudoUniqueFile, int> entry in frameCountCache) { if (entry.Key.path == hash.path && entry.Key.filesize == hash.filesize) { return(true); } } return(false); }