private void Worker_Stop() { Bt_Stop.Enabled = false; if (worker_process != null) { worker_process.Cancel(); } }
private CompletionStatus ExecuteComplex(string src, string dst) { string DstEncode = GetPathWithoutExtension(dst) + "_.mp4"; string DstExtract = GetPathWithoutExtension(dst) + "_.mkv"; string DstAac = GetPathWithoutExtension(dst) + "_.aac"; jobId++; CompletionStatus Result; FFmpegConfig.UserInterfaceManager.Start(jobId, "Encoding to H264/AAC (Complex)"); ProcessStartOptions OptionsMain = new ProcessStartOptions(jobId, "", true); FFmpegProcess ProcessMain = null; OptionsMain.Started += (sender, e) => { ProcessMain = e.Process; }; Task <CompletionStatus> TaskMain = Task.Run(() => MediaEncoder.Encode(src, "h264", null, "", DstEncode, OptionsMain)); ProcessStartOptions Options = new ProcessStartOptions(jobId, "Extracting Audio", false); Result = MediaMuxer.ExtractAudio(src, DstExtract, Options); if (Result == CompletionStatus.Success) { Options.Title = "Encoding Audio"; Result = MediaEncoder.Encode(DstExtract, null, "aac", null, DstAac, Options); } if (Result != CompletionStatus.Success) { ProcessMain?.Cancel(); } TaskMain.Wait(); CompletionStatus Result2 = TaskMain.Result; if (Result == CompletionStatus.Success && Result2 == CompletionStatus.Success) { Options.Title = "Muxing Audio and Video"; Result = MediaMuxer.Muxe(DstEncode, DstAac, dst, Options); } File.Delete(DstEncode); File.Delete(DstExtract); File.Delete(DstAac); FFmpegConfig.UserInterfaceManager.Stop(jobId); return(Result); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (ClosingState == 0) { ClosingState = HasRunningHosts ? 1 : 2; autoClose = true; CancelButton.Content = "Cancelling..."; CancelButton.IsEnabled = false; task?.Cancel(); foreach (FFmpegProcess host in hosts) { host.Cancel(); } } if (ClosingState == 1) { e.Cancel = true; } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { host?.Cancel(); task?.Cancel(); }