public override void Close() { try { mMediaTask.Stop(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
protected override void OnClosing(CancelEventArgs e) { _renderRunning = false; task.Stop(true); _traking.Dispose(); _detection.Dispose(); _recognize.Dispose(); Marshal.FreeHGlobal(_pImage); base.OnClosing(e); }
private void burn_Click(object sender, EventArgs e) { // Destroy all the writers... if (_VideoWriter != null) { _VideoWriter.Close(); _VideoWriter.Dispose(); _VideoWriter = null; } if (_AudioWriter != null) { _AudioWriter.Close(); _AudioWriter.Dispose(); _AudioWriter = null; } if (_EncodeTask != null) { _EncodeTask.Stop(); _EncodeTask = null; } if (_EncodedStream != null) { _EncodedStream.Close(); _EncodedStream.Dispose(); _EncodedStream = null; } // Make the audio a WAV var sampleData = File.ReadAllBytes(_RawAudioFile); using (var waveStream = new MemoryStream()) { using (var bw = new BinaryWriter(waveStream)) { var audioSampleRate = (int)_AudioSampleRate; bw.Write(new char[4] { 'R', 'I', 'F', 'F' }); int fileSize = 36 + sampleData.Length; bw.Write(fileSize); bw.Write(new char[8] { 'W', 'A', 'V', 'E', 'f', 'm', 't', ' ' }); bw.Write((int)16); bw.Write((short)1); bw.Write((short)_AudioChannels); bw.Write(audioSampleRate); bw.Write((int)(audioSampleRate * ((_AudioSampleDepth * _AudioChannels) / 8))); bw.Write((short)((_AudioSampleDepth * _AudioChannels) / 8)); bw.Write((short)_AudioSampleDepth); bw.Write(new char[4] { 'd', 'a', 't', 'a' }); bw.Write(sampleData.Length); bw.Write(sampleData, 0, sampleData.Length); waveStream.Position = 0; File.WriteAllBytes(_WavAudioFile, waveStream.ToArray()); } } // Combine them _VideoConverter.ConvertMedia(_EncodedVideoFile, "h264", _FinalFile, null, new ConvertSettings() { CustomOutputArgs = " -i " + _WavAudioFile + " -vcodec libx264 -acodec libmp3lame", }); }