Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. private async void RunFfmpeg()
  2. {
  3. await Task.Run(() =>
  4. {
  5. String destFolder = null;
  6. String sourceFolder = null;
  7. int listCount = 0;
  8.  
  9. this.Dispatcher.Invoke(() =>
  10. {
  11. destFolder = textDest.Text;
  12. sourceFolder = textSource.Text;
  13. listCount = listFiles.Items.Count;
  14. });
  15.  
  16.  
  17.  
  18. foreach (FileInfo fileC in listFiles.Items)
  19. {
  20. //Changing old extension to mp4
  21. string oldFileName = fileC.ToString();
  22. string newFileName = null;
  23.  
  24. string[] extension = oldFileName.Split('.');
  25.  
  26. newFileName = extension[0] + ".mp4";
  27.  
  28. string newDir = destFolder + "\" + extension[0];
  29. DirectoryInfo createDir = new DirectoryInfo(newDir);
  30.  
  31. if (!createDir.Exists)
  32. {
  33. createDir.Create();
  34. }
  35.  
  36. //Gathering folders and all I need...
  37. string output = """ + destFolder + "\" + extension[0] + "\" + newFileName + """;
  38. string input = """ + sourceFolder + "\" + oldFileName + """;
  39.  
  40. var startInfo = new System.Diagnostics.ProcessStartInfo
  41. {
  42. FileName = "cmd.exe",
  43. //Arguments = $"-i {input} {output}",
  44. Arguments = $"/c ffmpeg -i {input}" + " -c:a copy -c:v copy " + $"{output}",
  45. UseShellExecute = false,
  46. RedirectStandardOutput = true,
  47. CreateNoWindow = false,
  48. WorkingDirectory = Directory.GetCurrentDirectory()
  49. };
  50. Process p = new Process();
  51. p.StartInfo = startInfo;
  52. p.OutputDataReceived += P_OutputDataReceived;
  53. p.Start();
  54. p.WaitForExit();
  55. }
  56. });
  57. }
  58.  
  59. private void P_OutputDataReceived(object sender, DataReceivedEventArgs e)
  60. {
  61. this.Dispatcher.Invoke(() =>
  62. {
  63. //string cmdBox = cmdOutput.Text;
  64. //cmdOutput.AppendText(cmdBox);
  65. //cmdOutput.Clear();
  66. cmdOutput.AppendText(e.Data);
  67. });
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement