void FfmpegMergeProcessExited(object sender, EventArgs e) { if (_ffmpegProcess.ExitCode == 0) { if (_pbMerge.Count > 0) { var ma = 0d; var fi = new FileInfo(_dir + _outfile); var alertData = new StringBuilder(); int durationSeconds = 0; foreach (var m in _pbMerge) { if (m.AlertData != "") { alertData.Append(m.AlertData); alertData.Append(","); } durationSeconds += m.DurationSeconds; if (m.MaxAlarm > ma) { ma = m.MaxAlarm; } } var ff = new FilesFile { CreatedDateTicks = DateTime.Now.Ticks, DurationSeconds = durationSeconds, IsTimelapse = false, TriggerLevel = _pbMerge.First().TriggerLevel, TriggerLevelMax = _pbMerge.First().TriggerLevelMax, Filename = _outfile, AlertData = Helper.GetMotionDataPoints(alertData), MaxAlarm = ma, SizeBytes = fi.Length, IsMergeFile = true, IsMergeFileSpecified = true }; string name; if (_currentObject.Ot == 1) { var vl = MainClass.GetVolumeLevel(_currentObject.ID); vl.AddFile(ff); name = vl.Micobject.name; } else { var cw = MainClass.GetCameraWindow(_currentObject.ID); cw.AddFile(ff); name = cw.Camobject.name; var fpv = _pbMerge.First(); //get preview image string imgname = fpv.Filename.Substring(0, fpv.Filename.LastIndexOf(".", StringComparison.Ordinal)); var imgpath = _dir + "thumbs/" + imgname + "_large.jpg"; if (File.Exists(imgpath)) { Image bmpPreview = Image.FromFile(imgpath); string jpgname = _dir + "thumbs\\" + ff.Filename.Substring(0, ff.Filename.LastIndexOf(".", StringComparison.Ordinal)); bmpPreview.Save(jpgname + "_large.jpg", MainForm.Encoder, MainForm.EncoderParams); Image.GetThumbnailImageAbort myCallback = ThumbnailCallback; Image myThumbnail = bmpPreview.GetThumbnailImage(96, 72, myCallback, IntPtr.Zero); myThumbnail.Save(jpgname + ".jpg", MainForm.Encoder, MainForm.EncoderParams); myThumbnail.Dispose(); bmpPreview.Dispose(); } } var fp = new FilePreview(_outfile, durationSeconds, name, ff.CreatedDateTicks, _currentObject.Ot, _currentObject.ID, ma, false, true); MainForm.MasterFileAdd(fp); MainForm.NeedsMediaRefresh = Helper.Now; } _pbMerge.Clear(); } else { Logger.LogErrorToFile("FFMPEG process exited with code " + _ffmpegProcess.ExitCode); MessageBox.Show(this, LocRm.GetString("ErrorCheckLogFile")); } DoClose(); }