public static void Commit(MontageAction action) { var now = DateTime.Now; var time = (int)(now - recordStartTime).TotalMilliseconds; var cmd = new MontageCommand { Action = action, Time = time, Id = Log.Id, }; MontageCommandIO.AppendCommand(cmd, FileName); Id++; if (action == MontageAction.Commit) { goodSplitTime += now - lastCommitTime; } if (action == MontageAction.CommitAndSplit) { goodStartTime += goodSplitTime; goodSplitTime = new TimeSpan(); } lastCommitTime = now; }
public static void Start() { recordStartTime = DateTime.Now; lastCommitTime = DateTime.Now; goodSplitTime = new TimeSpan(); goodStartTime = new TimeSpan(); Id = 0; MontageCommandIO.Clear(FileName); }
static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("Assembler <dir>"); return; } Directory.SetCurrentDirectory(args[0]); // to avoid ugly arg[0]+"\\blahblah" var titles = File.ReadAllLines(TitlesFileName); var subtitles = File.ReadAllLines(SubtitlesFileName).ToList(); int title = int.Parse(args[0]); // assume <dir> has arbitrary name, not integer XDocument doc = XDocument.Load("list.xspf"); var tracks = doc .Elements() .Where(z => z.Name.LocalName == "playlist") .Elements() .Where(z => z.Name.LocalName == "trackList") .Elements() .Select(z => z.Elements().Where(x => x.Name.LocalName == "location").FirstOrDefault()) .Select(z => z.Value) .Select(z => z.Substring(8, z.Length - 8)) .Select(z => z.Replace("/", "\\")) .Select(z => new FileInfo(z).Name) .ToList(); var log = MontageCommandIO.ReadCommands("log.txt"); var parts = CreateParts(tracks, log, title); var batFile = new StreamWriter("Assembly.bat", false, Encoding.GetEncoding(866)); batFile.WriteLine("del processing\\processed*"); batFile.WriteLine("del result*"); var context = new BatchCommandContext { batFile = batFile, lowQuality = false }; foreach (var part in parts.Parts) { part.WritePartToBatch(context); } batFile.Close(); }
static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("Assembler <dir>"); Console.ReadKey(); return; } XDocument doc = XDocument.Load(args[0] + "\\list.xspf"); var relative = new FileInfo(args[0]).DirectoryName + "\\"; var tracks = doc .Elements() .Where(z => z.Name.LocalName == "playlist") .Elements() .Where(z => z.Name.LocalName == "trackList") .Elements() .Select(z => z.Elements().Where(x => x.Name.LocalName == "location").FirstOrDefault()) .Select(z => z.Value) .Select(z => z.Substring(8, z.Length - 8)) .Select(z => z.Replace("/", "\\")) .Select(z => new FileInfo(z).Name) .ToArray(); var breaks = MontageCommandIO.ReadCommands(args[0] + "\\log.txt") .Commands .Where(z => z.Action == MontageAction.CommitAndSplit) .Select(z => z.Id) .ToArray(); var resList = new List <List <string> >(); resList.Add(new List <string>()); int current = 0; foreach (var e in tracks) { int number = int.Parse(e.Substring(5, 3)); if (current < breaks.Length && number > breaks[current]) { current++; resList.Add(new List <string>()); } resList[resList.Count - 1].Add(e); } var high = new StreamWriter(args[0] + "\\AssemblyHigh.bat"); for (int i = 0; i < resList.Count; i++) { var list = resList[i]; var listFile = new StreamWriter(args[0] + "\\FileList" + i.ToString() + ".txt"); var concat = ""; foreach (var file in list) { if (concat != "") { concat += "|"; } concat += "chunks\\new-" + file; listFile.WriteLine("file 'chunks\\" + file + "'"); } listFile.Close(); high.WriteLine("ffmpeg -f concat -i FileList" + i.ToString() + ".txt -qscale 0 result-" + i.ToString() + ".avi"); } high.Close(); //var bat=new StreamWriter(args[0]+"\\AssemblyLow.bat"); //bat.WriteLine("del chunks\\new*.*"); //var concat = ""; //foreach (var e in tracks) //{ // var z=new FileInfo(e); // bat.WriteLine("ffmpeg -i chunks\\" + z.Name+" -vcodec copy -acodec libmp3lame -ar 44100 -ab 32k chunks\\"+"new-" + z.Name); // list.WriteLine("file 'chunks\\" + z.Name + "'"); // if (concat != "") concat += "|"; // concat += "chunks\\new-" + z.Name; //} //bat.WriteLine("ffmpeg -i \"concat:" + concat + "\" -c copy result.avi"); //bat.Close(); //list.Close(); //File.WriteAllText(args[0] + "\\AssemblyHigh.bat", // "ffmpeg -f concat -i FileList.txt -qscale 0 result.avi"); }
static void ExportV0(DirectoryInfo rootFolder, DirectoryInfo videoFolder, MontageModelV4 model) { File.WriteAllLines(videoFolder.FullName + "\\titles.txt", model.Information.Episodes.Select(z => z.Name).Where(z => z != null).ToArray(), Encoding.UTF8); var file = videoFolder.FullName + "\\log.txt"; MontageCommandIO.Clear(file); MontageCommandIO.AppendCommand(new MontageCommand { Action = MontageAction.StartFace, Id = 1, Time = 0 }, file); MontageCommandIO.AppendCommand(new MontageCommand { Action = MontageAction.StartScreen, Id = 2, Time = model.Shift }, file); int id = 3; var list = model.Chunks.ToList(); list.Add(new ChunkDataV4 { StartTime = list[list.Count - 1].StartTime + list[list.Count - 1].Length, Length = 0, Mode = Mode.Undefined }); var oldMode = Mode.Drop; for (int i = 0; i < list.Count; i++) { var e = list[i]; bool newEp = false; if (e.Mode != oldMode || e.StartsNewEpisode || i == list.Count - 1) { var cmd = new MontageCommand(); cmd.Id = id++; cmd.Time = e.StartTime; switch (oldMode) { case Mode.Drop: cmd.Action = MontageAction.Delete; break; case Mode.Face: cmd.Action = MontageAction.Commit; break; case Mode.Screen: cmd.Action = MontageAction.Commit; break; case Mode.Undefined: cmd.Action = MontageAction.Delete; break; } MontageCommandIO.AppendCommand(cmd, file); oldMode = e.Mode; newEp = true; } if (e.StartsNewEpisode) { MontageCommandIO.AppendCommand( new MontageCommand { Id = id++, Action = MontageAction.CommitAndSplit, Time = e.StartTime }, file ); newEp = true; } if (newEp) { if (e.Mode == Mode.Face || e.Mode == Mode.Screen) { var cmd = new MontageCommand(); cmd.Id = id++; cmd.Time = e.StartTime; switch (e.Mode) { case Mode.Face: cmd.Action = MontageAction.Face; break; case Mode.Screen: cmd.Action = MontageAction.Screen; break; } MontageCommandIO.AppendCommand(cmd, file); } } } }