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

using Apewer;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Apewer.Run
{
public class Batch
{
public Batch() => ConvertBreakingBad();
public void ConvertBreakingBad()
{
var paths = StorageUtility.GetSubFiles(@"E:\Breaking Bad");
var outdir = @"D:\temp\bb";
foreach (var path in paths)
{
var name = Path.GetFileName(path);
Console.Title = name;
Console.Clear();
if (name.EndsWith(".mkv"))
{
var mp4path = Path.Combine(outdir, name.Replace(".mkv", ".mp4"));
if (StorageUtility.FileExists(mp4path)) continue;
var cmd = "ffmpeg.exe";
var arg = $"-i \"{path}\" -vcodec copy -acodec copy \"{mp4path}\"";
SystemUtility.RunConsole(cmd, arg, (s) => Console.WriteLine(s));
continue;
}
if (name.EndsWith(".srt"))
{
continue;
var srtpath = Path.Combine(outdir, name);
var vttpath = Path.Combine(outdir, name.Replace(".srt", ".vtt"));
var text = StorageUtility.ReadFile(path).ToText(Encoding.Default);
StorageUtility.WriteFile(srtpath, text.ToBinary());
SystemUtility.RunConsole("ffmpeg.exe", $"-i \"{srtpath}\" \"{vttpath}\"", (s) => Console.WriteLine(s));
continue;
}
}
}
}
}