From bbed863a87c40fc6e189bc1541ce8a578079a644 Mon Sep 17 00:00:00 2001 From: Rikux3 Date: Sun, 19 Jul 2020 01:10:48 +0200 Subject: [PATCH] Be more verbose, create output directory if not exists --- UsmToolkit/Program.cs | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/UsmToolkit/Program.cs b/UsmToolkit/Program.cs index c7608c4..e02d05f 100644 --- a/UsmToolkit/Program.cs +++ b/UsmToolkit/Program.cs @@ -89,6 +89,7 @@ namespace UsmToolkit Console.WriteLine($"File: {fileName}"); var usmStream = new CriUsmStream(fileName); + Console.WriteLine("Demuxing..."); usmStream.DemultiplexStreams(new MpegStream.DemuxOptionsStruct() { AddHeader = false, @@ -100,12 +101,21 @@ namespace UsmToolkit if (Join) { + if (!string.IsNullOrEmpty(OutputDir) && !Directory.Exists(OutputDir)) + Directory.CreateDirectory(OutputDir); + JoinOutputFile(usmStream); } } private void JoinOutputFile(CriUsmStream usmStream) { + if (!File.Exists("config.json")) + { + Console.WriteLine("ERROR: config.json not found!"); + return; + } + var audioFormat = usmStream.FinalAudioExtension; var pureFileName = Path.GetFileNameWithoutExtension(usmStream.FilePath); @@ -115,24 +125,23 @@ namespace UsmToolkit //need vgmstream to format that to wav if (!Directory.Exists("vgmstream")) { - Console.WriteLine("WARNING: vgmstream folder not found!"); + Console.WriteLine("ERROR: vgmstream folder not found!"); + return; } + Console.WriteLine("adx audio detected, convert to wav..."); Helpers.ExecuteProcess("vgmstream/test.exe", $"\"{Path.ChangeExtension(usmStream.FilePath, usmStream.FinalAudioExtension)}\" -o \"{Path.ChangeExtension(usmStream.FilePath, "wav")}\""); usmStream.FinalAudioExtension = ".wav"; } - if (!File.Exists("config.json")) - { - Console.WriteLine("ERROR: config.json not found!"); - return; - } Helpers.ExecuteProcess("ffmpeg", CreateFFmpegParameters(usmStream, pureFileName)); if (CleanTempFiles) { + Console.WriteLine($"Cleaning up temporary files from {pureFileName}"); + File.Delete(Path.ChangeExtension(usmStream.FilePath, "wav")); File.Delete(Path.ChangeExtension(usmStream.FilePath, "adx")); File.Delete(Path.ChangeExtension(usmStream.FilePath, "hca")); @@ -174,9 +183,10 @@ namespace UsmToolkit DepsConfig conf = JsonConvert.DeserializeObject(File.ReadAllText("deps.json")); WebClient client = new WebClient(); - //ffmpeg + Console.WriteLine($"Downloading ffmpeg from {conf.FFmpeg}"); client.DownloadFile(conf.FFmpeg, "ffmpeg.zip"); + Console.WriteLine($"Extracting ffmpeg..."); using (ZipArchive archive = ZipFile.OpenRead("ffmpeg.zip")) { var ent = archive.Entries.FirstOrDefault(x => x.Name == "ffmpeg.exe"); @@ -185,12 +195,13 @@ namespace UsmToolkit ent.ExtractToFile("ffmpeg.exe", true); } } - File.Delete("ffmpeg.zip"); - //vgmstream + Console.WriteLine($"Downloading vgmstream from {conf.Vgmstream}"); client.DownloadFile(conf.Vgmstream, "vgmstream.zip"); - ZipFile.ExtractToDirectory("vgmstream.zip", "vgmstream"); + + Console.WriteLine("Extracting vgmstream..."); + ZipFile.ExtractToDirectory("vgmstream.zip", "vgmstream", true); File.Delete("vgmstream.zip"); return 0;