Example #1
0
        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 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);
        }