You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.6 KiB

  1. using Apewer;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Text;
  6. namespace Apewer.Run
  7. {
  8. public class Batch
  9. {
  10. public Batch() => ConvertBreakingBad();
  11. public void ConvertBreakingBad()
  12. {
  13. var paths = StorageUtility.GetSubFiles(@"E:\Breaking Bad");
  14. var outdir = @"D:\temp\bb";
  15. foreach (var path in paths)
  16. {
  17. var name = Path.GetFileName(path);
  18. Console.Title = name;
  19. Console.Clear();
  20. if (name.EndsWith(".mkv"))
  21. {
  22. var mp4path = Path.Combine(outdir, name.Replace(".mkv", ".mp4"));
  23. if (StorageUtility.FileExists(mp4path)) continue;
  24. var cmd = "ffmpeg.exe";
  25. var arg = $"-i \"{path}\" -vcodec copy -acodec copy \"{mp4path}\"";
  26. WindowsUtility.RunConsole(cmd, arg, (s) => Console.WriteLine(s));
  27. continue;
  28. }
  29. if (name.EndsWith(".srt"))
  30. {
  31. continue;
  32. var srtpath = Path.Combine(outdir, name);
  33. var vttpath = Path.Combine(outdir, name.Replace(".srt", ".vtt"));
  34. var text = StorageUtility.ReadFile(path).ToText(Encoding.Default);
  35. StorageUtility.WriteFile(srtpath, text.ToBinary());
  36. WindowsUtility.RunConsole("ffmpeg.exe", $"-i \"{srtpath}\" \"{vttpath}\"", (s) => Console.WriteLine(s));
  37. continue;
  38. }
  39. }
  40. }
  41. }
  42. }