private void GoExtract(bool audioOrVideo, string suggestedFormat) { var files = Utils.SplitByString(txtInput.Text, ";"); if (txtInput.Text.Trim() == "" || files.Length == 0) { MessageBox.Show("No files chosen."); } List <ProcessStartInfo> tasks = new List <ProcessStartInfo>(); foreach (var file in files) { if (!File.Exists(file)) { MessageBox.Show("Input file " + file + "does not exist"); return; } if (!file.ToLowerInvariant().EndsWith(".m4a") && !file.ToLowerInvariant().EndsWith(".mp4") && !file.ToLowerInvariant().EndsWith(".m4v")) { if (!Utils.AskToConfirm("Might not work, the file is not a m4a/mp4/m4v" + "... continue?")) { return; } } ProcessStartInfo task = MakeTask(audioOrVideo, suggestedFormat, file); tasks.Add(task); } _runner.RunProcesses(tasks.ToArray(), "Extract " + (audioOrVideo ? "Audio" : "Video")); }
private void doCustomEncode(string example, InputBoxHistory key) { var files = this.GetInputFiles(1); var cmd = InputBoxForm.GetStrInput("Command for the ffmpeg encoder:", example, key); if (String.IsNullOrEmpty(cmd)) { return; } else if (!cmd.Contains("%in%") && !Utils.AskToConfirm("Did not see '%in%', " + "won't process input files. Continue?")) { return; } if (!Utils.AskToConfirm("Run the command right now? (or copy the command line to the clipboard)")) { var s = ""; foreach (var file in files) { s += "\r\n\"" + CsDownloadVidFilepaths.GetFfmpeg() + "\" "; s += cmd.Replace("%in%", files[0]); } Clipboard.SetText(s); MessageBox.Show("Command was copied to the clipboard."); return; } RunToolHelper.RunAndCatch(() => { var infos = new List <ProcessStartInfo>(); foreach (var file in files) { var info = new ProcessStartInfo(); info.FileName = CsDownloadVidFilepaths.GetFfmpeg(); info.Arguments = cmd.Replace("%in%", file); info.CreateNoWindow = true; info.RedirectStandardError = true; info.RedirectStandardOutput = true; info.UseShellExecute = false; infos.Add(info); } _runner.RunProcesses(infos.ToArray(), "Custom encode"); }); }
private void btnDownload_Click(object sender, EventArgs e) { RunToolHelper.RunAndCatch(() => { if (chkDashToM4a.Checked || chkAutoCombineAV.Checked) { CsDownloadVidFilepaths.GetFfmpeg(); } GetOptionsFromUI(out List <string> urlsRet, out int waitBetween, out string filenamePattern, out string outDir); var formats = GetFormatsFromUI(); if (formats == null || formats.Length == 0) { throw new CsDownloadVidException("No format chosen."); } else if (formats.Any((fmt) => cbUsePytube.Checked != fmt.StartsWith("<Stream:"))) { throw new CsDownloadVidException("It looks like you've clicked " + "'use pytube instead of ytdl' half-way through-- when you change " + "this you have to start over at step 1."); } Configs.Current.Set(ConfigKey.SaveVideosTo, txtOutputDir.Text); _runner.SetWaitBetween(waitBetween); List <ProcessStartInfo> listInfos = new List <ProcessStartInfo>(); foreach (var url in urlsRet) { foreach (var fmt in formats) { listInfos.Add(GetStartInfo(url, fmt, false)); } } _runner.RunProcesses(listInfos.ToArray(), "downloading", () => { if (chkAutoCombineAV.Checked && Directory.Exists(txtOutputDir.Text)) { runAutocombineAVAll(txtOutputDir.Text); } }); }); }