static void InitForBusinessLogic() { //如果数据库文件不存在,则建立数据库文件 PornDatabase.CreateDatabase(); PornClassifier.Init(); FFMPEGWrapper.Init(); WechatForm.Init(); update_domain_list_timer = new System.Threading.Timer(PornDatabase.UpdateDatabase, null, new TimeSpan(0, 0, 5), new TimeSpan(4, 0, 0)); delete_history_timer = new System.Threading.Timer(PornDatabase.DeleteHistroy, null, new TimeSpan(0, 1, 0), System.Threading.Timeout.InfiniteTimeSpan); }
public bool ClassifyVideoFile(string filename, out Exception excep) { log.Info("Classify Video File: " + filename); FFMPEGWrapper ffmpeg = new FFMPEGWrapper(); if (!ffmpeg.Open(filename)) { log.Info("Video File Cannot Open: " + filename); excep = new Exception("Cannot Open File!"); ffmpeg.Dispose(); return(false); } log.Debug("Video File Opened: " + filename); if (ffmpeg.FileInfo.nb_frames < MinFrames) { log.Info("Video File Short of Frames: " + filename + " frames: " + ffmpeg.FileInfo.nb_frames);; ffmpeg.Dispose(); excep = new Exception("Video File Too Short"); return(false); } Int64 step = ffmpeg.FileInfo.duration / VideoSegments; PornClassifier.ImageType [] types = new PornClassifier.ImageType[VideoSegments - 1]; int pornNum = 0; for (Int64 ts = step; ts < ffmpeg.FileInfo.duration - step / 2; ts += step) { if (ffmpeg.ReadFrame(ts)) { if (Instance.Classify(ffmpeg.FileInfo.pdata, ffmpeg.FileInfo.width, ffmpeg.FileInfo.height, ffmpeg.FileInfo.linesize) == ImageType.P**n) { pornNum++; } } } ffmpeg.Dispose(); excep = null; if (pornNum >= PornNumThd) { log.Info("P**n Video File: " + filename); return(true); } else { return(false); } }