/// <summary> /// flac > wav > split > gain /// </summary> /// <param name="flist"></param> public static void JobWavSplitGain(CommandJobData j) { foreach (var f in j.fileInfoList) { var filepath = f.filepath; if (filepath.Contains(".flac")) { var f1 = filepath.GetDirectory().changeShortPath() + "\\" + filepath.getFileName(); var f2 = MainWindowHelper.ChangeOutputFileName(j.outputDir, filepath, "wav"); StartProcess( "flac", "-d {0} -o {1}".format(f1.quote(), f2.quote())); filepath = filepath.replace(".flac", ".wav"); } Helper.SetCurrentDirectory(filepath.GetDirectory()); var outputDir = selectOutputDir(j.outputDir, filepath).changeShortPath(); var wavdir = outputDir + "\\" + filepath.GetBaseName() + "_WAV"; MessageProcessStatus("splitWav ..."); SplitWav(wavdir, filepath); //分割WavをCueSheetを元にリネーム MessageProcessStatus("applyWavDirCueSheet ..."); ApplyWavDirCueSheet(wavdir, filepath); var files = Directory.GetFiles(wavdir, "*", System.IO.SearchOption.AllDirectories) .Where(a => a.getExt() == ".wav") .ToArray(); foreach (var ff in files) { Debug.Log(ff); } //parallelCommand( flist, ( i, fileinfo, outputDir ) => { //} int num = 0; Parallel.For(0, files.Length, MainWindow.m_parallelOptions, i => { try { num++; MessageProcessStatus($"処理中... ({num}/{files.Length})"); StartProcess("WaveGain", "-r -y {0}".format(files[i].quote())); } catch (Exception e) { MainWindowHelper.SetExceptionLog(e); } }); } MessageProcessComplete(@"「WavSplitGain」が完了しました"); }
/// <summary> /// CDバッチ処理 /// </summary> /// <param name="j"></param> public static void JobCDFlac(CommandJobData j) { RunParallel(j, (i, f, outputDir) => { if (!f.hasWav()) { MainWindowHelper.SetNotifyText("jobCDBatch: {0}は対応していません".format(f.format), NotifyType.Warning); return; //continue; } var filepath = f.filepath; Helper.SetCurrentDirectory(filepath.GetDirectory()); var fname = filepath.GetBaseName(); var cueFile = filepath.ChangeExtention("cue"); if (!File.Exists(cueFile)) { MainWindowHelper.SetNotifyText("makeTaskFlacPack: {0}が見つかりませんでした".format(cueFile.getFileName()), NotifyType.Warning); return; //continue; } string newfilepath = MainWindowHelper.ChangeOutputFileName(j.outputDir, filepath, "flac"); //if( File.Exists( newfilepath ) ) { // File.Delete( newfilepath ); //} { var zfile = newfilepath.ChangeExtention("zip"); if (File.Exists(zfile)) { File.Delete(zfile); } } var logFile = fname + ".log"; var jpgFile = fname + ".jpg"; var jpgOpt = "--picture=\"{0}\"".format(jpgFile); if (!File.Exists(filepath.ChangeExtention("jpg"))) { DialogResult result = MessageBox.Show( String.Format("[{0}.jpg] が見つかりませんでした。\n画像の埋め込み「なし」で継続しますがよろしいですか?", fname), "what is this", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { return; } jpgOpt = ""; jpgFile = ""; } var cueOpt = "--tag-from-file=\"CUESHEET={0}.cue\"".format(fname); var opt = "-8 --replay-gain {0} {1} \"{2}.wav\" -o {3}".format(jpgOpt, cueOpt, fname, newfilepath.quote()); MainWindowHelper.SetNotifyText("flacでエンコード中... [{0}]".format(filepath.getFileName()), interval: 0); StartProcess("flac", opt); StringBuilder s = new StringBuilder(); s.Append("a -y -mx=0 {0} {1}".format(newfilepath.ChangeExtention("zip").quote(), newfilepath.quote())); //string[] addFile = { logFile, jpgFile, cueFile.getFileName() }; var addFile = (new string[] { logFile, jpgFile, cueFile.getFileName() }) .Where(a => !string.IsNullOrEmpty(a)) .Where(a => File.Exists(a)) .Select(a => a.quote()) .ToArray() ; //foreach( var a in addFile ) { // if( a == null || a == "" ) continue; // if( File.Exists( a ) ) { // s.Append( " " ); // s.Append( a.quote() ); // } // else { // setProcessLog( "{0}: not found".format( a ) ); // } //} s.Append(" "); s.Append(string.Join(" ", addFile)); string[] addFolder = { "DVD", "特典DVD", "ブックレット" }; foreach (var a in addFolder) { if (Directory.Exists(a)) { s.Append(" "); s.Append(a.quote()); } } MainWindowHelper.SetNotifyText("zip圧縮中... [{0}]".format(filepath.getFileName().ChangeExtention("zip"))); StartProcess("7z", s.ToString()); }); MainWindowHelper.SetNotifyText(@"「CD -> FLAC」が完了しました"); }
public static void JobSoundParge(CommandJobData j) { foreach (var aa in j.fileInfoList) { // console.log( a.getExt() ); var a = aa.filepath; using (var p = new System.Diagnostics.Process()) { p.StartInfo.FileName = @"ffprobe"; p.StartInfo.Arguments = "{0}".format(a.quote()); p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.Start(); //string hoge = p.StandardOutput.ReadToEnd(); //string hoge2 = p.StandardError.ReadToEnd(); Debug.Log("{0} {1}".format(p.StartInfo.FileName, p.StartInfo.Arguments)); string[] s = p.StandardError.ReadToEnd().Replace("\r", "").Split('\n'); foreach (var line in s) { var match = Regex.Matches(line, @"^Input"); if (match.Count != 0) { Debug.Log(line); } if (Regex.Matches(line, @"Stream").Count != 0) { Debug.Log(line); } var match2 = Regex.Matches(line, @"Stream #([0-9]):([0-9]).*: Audio: ([a-zA-Z0-9_]+)"); if (match2.Count != 0) { var m = match2[0]; Debug.Log("#{0}:{1} {2}".format(m.Groups[1].Value, m.Groups[2].Value, m.Groups[3].Value)); var ext = m.Groups[3].Value; switch (ext) { case "aac": StartProcess("ffmpeg", "-i {0} -vn -acodec copy {1}".format(a.quote(), MainWindowHelper.ChangeOutputFileName(j.outputDir, a, "m4a").quote())); break; case "vorbis": StartProcess("ffmpeg", "-i {0} -vn -acodec copy {1}".format(a.quote(), MainWindowHelper.ChangeOutputFileName(j.outputDir, a, "ogg").quote())); break; case "mp3": StartProcess("ffmpeg", "-i {0} -vn -acodec copy {1}".format(a.quote(), MainWindowHelper.ChangeOutputFileName(j.outputDir, a, "mp3").quote())); break; } } } p.WaitForExit(); } } }
/// <summary> /// WAVファイルに変換するジョブ /// </summary> /// <param name="j"></param> public static void JobCnvWAV(CommandJobData j) { Helper.SetCurrentDirectory(j.fileInfoList[0].filepath.GetDirectory()); int num = 0; RunParallel(j, (i, fileinfo, outputDir) => { num++; MainWindowHelper.SetNotifyText($"処理中({num}/{j.fileInfoList.Count})", interval: 0); if (fileinfo.hasWav()) { Log.Warning($"[{fileinfo.filepath}] WAVEフォーマットなので無視します"); return; } var filepath = fileinfo.filepath.GetDirectory().changeShortPath() + "\\" + fileinfo.filepath.getFileName(); var filepath2 = fileinfo.filepath.GetDirectory() + "\\" + fileinfo.filepath.getFileName(); string newfilepath = MainWindowHelper.ChangeOutputFileName(outputDir, filepath, "wav"); switch (fileinfo.format) { case "BMS": newfilepath = MainWindowHelper.ChangeOutputFileName(outputDir, null, "wav", fixedFileName($"{fileinfo.artist} - {fileinfo.trackName}")); StartProcess( "bmx2wavc", $"{filepath.quote()} {newfilepath.quote()}"); break; case "XWM": StartProcess( "xwmaencode", $"{filepath.quote()} {newfilepath.quote()}"); break; case "FUZ": StartProcess( "Fuz_extractor", $"-e {filepath.quote()}"); StartProcess( "xwmaencode", $"{MainWindowHelper.ChangeOutputFileName( outputDir, filepath2, "xwm" ).quote()} {newfilepath.quote()}"); var sss = MainWindowHelper.ChangeOutputFileName(outputDir, filepath2, "xwm"); if (File.Exists(sss)) { File.Delete(sss); } break; case FORMAT_FLAC: StartProcess( "flac", "-d {0} -o {1}".format(filepath.quote(), newfilepath.quote())); break; default: StartProcess( "ffmpeg", "-i {0} -y {1}".format(filepath.quote(), newfilepath.quote())); break; } if (!fileinfo.noMediaInfo) { TagInfo tag1 = Tsukikage.DllPInvoke.MP3Tag.MP3Infp.LoadTag(newfilepath); tag1.Album = fileinfo.album; tag1.Artist = fileinfo.artist; tag1.Title = fileinfo.trackName; tag1.CreationDate = fileinfo.recordedDate; tag1.Genre = fileinfo.genre; tag1.Comment = fileinfo.comment; //tag1.Duration = fileinfo.duration; //tag1.TrackNumber = fileinfo.trackIndex + "/" + fileinfo.trackTotal; tag1.TrackNumber = fileinfo.trackIndex; Debug.Log("{0}/{1} {2}/{3}".format(fileinfo.trackIndex, fileinfo.trackTotal, fileinfo.discIndex, fileinfo.discTotal)); Tsukikage.DllPInvoke.MP3Tag.MP3Infp.SaveTagInfoUnicode(tag1); } }); MainWindowHelper.SetNotifyText(@"「WAVに変換」が完了しました"); }