public void DoWork(EditorModel model, bool print) { var epsodes = ListEpisodes(model.Montage.FileChunks).Select(e => MakeEpisode(model, e)); var i = 0; foreach (var episode in epsodes) { var avsContext = new AvsContext(); episode.SerializeToContext(avsContext); var avsScript = avsContext.Serialize(model.Locations.AvsLibrary, model.Locations.AutoLevelsLibrary); var avsFile = model.Locations.AvsTempFile; using (var file = new StreamWriter(avsFile.OpenWrite())) { file.WriteLine(avsScript); } var videoFile = model.Locations.Make(model.VideoFolder, string.Format("{0:D2}.avi", i)); // TODO: real filename videoFile.Delete(); // TODO: move all cleanup to one method var ffmpegCommand = new RenderAvsScript { AvsInput = avsFile, VideoOutput = videoFile }; ffmpegCommand.Execute(print); i++; } }
public override void SerializeToContext(AvsContext context) { id = context.Id; Payload.SerializeToContext(context); var video = Payload.Id; var script = string.Format(Format, Id, video); context.AddData(script); }
public override void SerializeToContext(AvsContext context) { id = context.Id; First.SerializeToContext(context); Second.SerializeToContext(context); var script = string.Format(Format, Id, First.Id, Second.Id); context.AddData(script); }
public override void SerializeToContext(AvsContext context) { id = context.Id; FadeFrom.SerializeToContext(context); FadeTo.SerializeToContext(context); var from = FadeFrom.Id; var to = FadeTo.Id; var script = string.Format(Format, Id, to, from, Duration); context.AddData(script); }
public override void Work() { var args = @"-i ""{0}"" -q:v 0 -vf ""scale=1280:720, fps=25"" -q:v 0 -acodec libmp3lame -ac 2 -ar 44100 -ab 32k ""{1}"""; var avsContext = new AvsContext(); episodeNode.SerializeToContext(avsContext); var avsScript = avsContext.Serialize(Model); var avsFile = Model.Locations.GetAvsStriptFile(episodeNumber); File.WriteAllText(avsFile.FullName, avsScript, Encoding.GetEncoding("Windows-1251")); var videoFile = Model.Locations.GetOutputFile(episodeInfo); if (videoFile.Exists) { videoFile.Delete(); } args = string.Format(args, avsFile.FullName, videoFile.FullName); filesToDelIfAborted.Add(videoFile.FullName); RunProcess(args, Model.Videotheque.Locations.FFmpegExecutable.FullName); }
public override void Work() { var src = pmodel.SourceInfo; List <AvsNode> chunks = new List <AvsNode>(); var tracks = pmodel.MediaTracks.OrderBy(x => x.LeftShiftInSeconds).ToList(); oldName = pmodel.SourceInfo.FullName; newName = Path.Combine(pmodel.SourceInfo.Directory.FullName, Guid.NewGuid().ToString() + ".avi"); File.Move(oldName, newName); double previous = 0; int index = 0; string mode = "main"; while (Math.Abs(previous - pmodel.Duration) >= 0.5 && tracks.Count != 0) { var avs = new AvsPatchChunk(); if (mode == "main") { var endTime = index >= tracks.Count ? pmodel.Duration : tracks[index].StartSecond + tracks[index].LeftShiftInSeconds; avs.Load(newName, previous, endTime); previous = endTime; chunks.Add(avs); mode = "patch"; continue; } var name = tracks[index].IsTutoPatch ? tracks[index].Path.LocalPath : Path.Combine(Model.Locations.TemporalDirectory.FullName, tracks[index].FullName.Name); avs.Load(name, tracks[index].StartSecond, tracks[index].EndSecond); chunks.Add(avs); previous = tracks[index].EndSecond + tracks[index].LeftShiftInSeconds; index++; mode = "main"; } if (tracks.Count == 0) { var s = new AvsPatchChunk(); s.Load(newName, 0, pmodel.Duration); chunks.Add(s); } var final = new AvsConcatList(); final.Items = chunks; var avsContext = new AvsContext(); AvsNode payload = final; if (pmodel.Subtitles.Count > 0) { var currentSub = new AvsSub(); foreach (var sub in pmodel.Subtitles) { currentSub = new AvsSub(); currentSub.Payload = payload; currentSub.X = (int)(sub.Pos.X * pmodel.Width / pmodel.ActualWidth); currentSub.Y = (int)(sub.Pos.Y * pmodel.Height / pmodel.ActualHeight + sub.HeightShift); currentSub.Start = sub.LeftShiftInSeconds; currentSub.End = sub.LeftShiftInSeconds + sub.EndSecond - sub.StartSecond; currentSub.Content = sub.Content; currentSub.FontSize = (sub.FontSize * pmodel.FontCoefficent).ToString(); currentSub.Stroke = sub.Stroke; currentSub.Foreground = sub.Foreground; payload = currentSub; } currentSub.SerializeToContext(avsContext); } else { final.SerializeToContext(avsContext); } var args = @"-i ""{0}"" -q:v 0 -vf ""scale=1280:720, fps=25"" -q:v 0 -acodec libmp3lame -ar 44100 -ab 32k ""{1}"" -y"; var avsScript = string.Format(@"import(""{0}"")", Model.Locations.AvsLibrary.FullName) + "\r\n" + avsContext.GetContent() + "var_0"; File.WriteAllText(newName + "test.avs", avsScript, Encoding.GetEncoding("Windows-1251")); //Патчер в аутпут все делает var scriptFile = newName + "test.avs"; var path = Model.Locations.GetFinalOutputFile(pmodel.EpisodeNumber).FullName; args = string.Format(args, scriptFile, path); RunProcess(args, Model.Videotheque.Locations.FFmpegExecutable.FullName); File.Delete(scriptFile); OnTaskFinished(); File.Move(newName, oldName); }