private void BuildCodecList() { comboBoxCodec.Items.Clear(); if (radioButtonAVI.Checked) { AVIExporter tempExporter = new AVIExporter { Width = 320, Height = 240, Filename = textBoxVideoFilename.Text }; tempExporter.Init(); string[] codecList = tempExporter.CodecList; tempExporter.Close(); foreach (var name in codecList) { comboBoxCodec.Items.Add(name); } comboBoxCodec.SelectedIndex = 0; } }
private void startExportButton_Click(object sender, EventArgs e) { exportProgressBar.Value = 0; errorLabel.Text = string.Empty; if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { _exporter = new AVIExporter(); _exporter.Path = System.IO.Path.GetDirectoryName(saveFileDialog.FileName); _exporter.Filename = System.IO.Path.GetFileName(saveFileDialog.FileName); _exporter.Timestamp = timestampCheckBox.Checked; List <ExportItem> exportItems = new List <ExportItem>(); foreach (ExportItem item in exportItemsListBox.Items) { exportItems.Add(item); } _exporter.StartExport(exportItems); var thread = new Thread(UpdateProgressThread); thread.Start(); cancelButton.Enabled = true; startExportButton.Enabled = false; } }
/// <summary> /// Now start the export /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonExport_Click(object sender, EventArgs e) { string destPath = _path; // Get the related audio devices var audioSources = new Item[0]; if (checkBoxRelated.Checked) { List <Item> allAudioSources = new List <Item>(); foreach (var camera in _cameraItems) { allAudioSources.AddRange(camera.GetRelated() .Where(x => x.FQID.Kind == Kind.Microphone || x.FQID.Kind == Kind.Speaker)); } audioSources = allAudioSources.ToArray(); } if (dateTimePickerStart.Value > dateTimePickerEnd.Value) { MessageBox.Show("Start time need to be lower than end time"); return; } if (radioButtonAVI.Checked) { if (textBoxVideoFilename.Text == "") { MessageBox.Show("Please enter a filename for the AVI file.", "Enter Filename"); return; } AVIExporter aviExporter = new AVIExporter { Filename = textBoxVideoFilename.Text, Codec = (string)comboBoxCodec.SelectedItem, AudioSampleRate = int.Parse(comboBoxSampleRate.SelectedItem.ToString()) }; if (checkBoxIncludeOverlayImage.Checked) { if (_overlayImageFileName == null) { MessageBox.Show("Please select an image file for the overlay image.", "Select image file"); return; } Bitmap overlayImage = (Bitmap)Image.FromFile(_overlayImageFileName); if (aviExporter.SetOverlayImage(overlayImage, AVIExporter.VerticalOverlayPositionTop, AVIExporter.HorizontalOverlayPositionLeft, 0.1, false) == false) { MessageBox.Show("Failed to set overlay image, error: " + aviExporter.LastErrorString, "Overlay image"); } } _exporter = aviExporter; destPath = Path.Combine(_path, "Exported Images\\" + MakeStringPathValid(_cameraItems.FirstOrDefault().Name)); } else if (radioButtonMKV.Checked) { if (textBoxVideoFilename.Text == "") { MessageBox.Show("Please enter a filename for the MKV file.", "Enter Filename"); return; } if (_cameraItems.Count > 1) { MessageBox.Show("Warning, the MKV Exporter will only export the data from the first camera in the list"); } _exporter = new MKVExporter { Filename = textBoxVideoFilename.Text }; destPath = Path.Combine(_path, "Exported Images\\" + MakeStringPathValid(_cameraItems.FirstOrDefault().Name)); } else { if (checkBoxEncrypt.Checked && textBoxEncryptPassword.Text == "") { MessageBox.Show("Please enter password to encrypt with.", "Enter Password"); return; } _exporter = new DBExporter(true) { Encryption = checkBoxEncrypt.Checked, EncryptionStrength = EncryptionStrength.AES128, Password = textBoxEncryptPassword.Text, SignExport = checkBoxSign.Checked, PreventReExport = checkBoxReExport.Checked, IncludeBookmarks = checkBoxIncludeBookmark.Checked }; } _exporter.Init(); _exporter.Path = destPath; foreach (var camera in _cameraItems) { _exporter.CameraList.Add(camera); } _exporter.AudioList.AddRange(audioSources); try { if (_exporter.StartExport(dateTimePickerStart.Value.ToUniversalTime(), dateTimePickerEnd.Value.ToUniversalTime())) { _timer.Tick += ShowProgress; _timer.Start(); buttonExport.Enabled = false; buttonCancel.Enabled = true; } else { int lastError = _exporter.LastError; string lastErrorString = _exporter.LastErrorString; labelError.Text = lastErrorString + " ( " + lastError + " )"; _exporter.EndExport(); } } catch (NoVideoInTimeSpanMIPException ex) { MessageBox.Show(ex.Message, "Start Export"); } catch (Exception ex) { EnvironmentManager.Instance.ExceptionDialog("Start Export", ex); } }