Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private async void RunFfmpeg()
- {
- await Task.Run(() =>
- {
- String destFolder = null;
- String sourceFolder = null;
- int listCount = 0;
- this.Dispatcher.Invoke(() =>
- {
- destFolder = textDest.Text;
- sourceFolder = textSource.Text;
- listCount = listFiles.Items.Count;
- });
- foreach (FileInfo fileC in listFiles.Items)
- {
- //Changing old extension to mp4
- string oldFileName = fileC.ToString();
- string newFileName = null;
- string[] extension = oldFileName.Split('.');
- newFileName = extension[0] + ".mp4";
- string newDir = destFolder + "\" + extension[0];
- DirectoryInfo createDir = new DirectoryInfo(newDir);
- if (!createDir.Exists)
- {
- createDir.Create();
- }
- //Gathering folders and all I need...
- string output = """ + destFolder + "\" + extension[0] + "\" + newFileName + """;
- string input = """ + sourceFolder + "\" + oldFileName + """;
- var startInfo = new System.Diagnostics.ProcessStartInfo
- {
- FileName = "cmd.exe",
- //Arguments = $"-i {input} {output}",
- Arguments = $"/c ffmpeg -i {input}" + " -c:a copy -c:v copy " + $"{output}",
- UseShellExecute = false,
- RedirectStandardOutput = true,
- CreateNoWindow = false,
- WorkingDirectory = Directory.GetCurrentDirectory()
- };
- Process p = new Process();
- p.StartInfo = startInfo;
- p.OutputDataReceived += P_OutputDataReceived;
- p.Start();
- p.WaitForExit();
- }
- });
- }
- private void P_OutputDataReceived(object sender, DataReceivedEventArgs e)
- {
- this.Dispatcher.Invoke(() =>
- {
- //string cmdBox = cmdOutput.Text;
- //cmdOutput.AppendText(cmdBox);
- //cmdOutput.Clear();
- cmdOutput.AppendText(e.Data);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement