Exemplo n.º 1
0
        public override void WriteToAvs(BatchCommandContext context)
        {
            var input  = GetInput(context, VideoInput);
            var script = String.Format(@"
                            {0}
                            FadeOutTime(video, {1})
                          ", input, EffectDuration);

            WriteAvsScript(context, script);
        }
Exemplo n.º 2
0
        // public IList<ProcessingItem> Items { get { return items.AsReadOnly(); } }

        public void WritePartToBatch(BatchCommandContext context)
        {
            FinalizePart();

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("========  {0}  ========", PartNumber);
            Console.ForegroundColor = ConsoleColor.Gray;

            //// pre-processing
            //context.batFile.WriteLine(@"..\ImageGenerator.exe ""{0}"" ""{1}"" ""{2}"" ""{3}"" ""{4}"" 1280 720 ""{5}""",
            //    "..\\picture.jpg",
            //    "..\\titles.txt",
            //    Title,
            //    "titles.txt",
            //    PartNumber,
            //    String.Format("intro_for_{0}.png", PartNumber)
            //    );


            foreach (var item in items)
            {
                Console.WriteLine(item.Caption);
                item.WriteToBatch(context);  // writes effects to .avs AND encoding command to .bat
            }

            if (!context.lowQuality)
            {
                // processing (concatenation)
                var listFile = new StreamWriter(String.Format("concat_{0}.txt", PartNumber));
                foreach (var item in items)
                {
                    listFile.WriteLine("file '{0}'", item.ResultFilename);
                }
                listFile.Close();
            }
            else
            {
                // recode to "low quality" and concatenate
                var listFile = new StreamWriter(String.Format("concat_{0}.txt", PartNumber));
                Directory.CreateDirectory(RecodeDir);
                foreach (var item in items)
                {
                    var name    = Path.GetFileName(item.ResultFilename);
                    var newName = Path.Combine(RecodeDir, name);
                    context.batFile.WriteLine("ffmpeg -i {0} -vcodec copy -acodec libmp3lame -ar 44100 -ab 32k {1}", item.ResultFilename, newName);
                    listFile.WriteLine("file '{0}'", item.ResultFilename);
                }
                listFile.Close();
            }
            context.batFile.WriteLine("ffmpeg -f concat -i concat_{0}.txt -qscale 0 result-{0}{1}.avi", PartNumber, context.lowQuality ? "_low" : "");


            // post-processing
            // TODO
        }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
        public override void WriteToAvs(BatchCommandContext context)
        {
            var pathToReference = Path.Combine(context.path, VideoReference);
            var pathToImage     = Path.Combine(context.path, ImageFile);
            var script          = String.Format(@"
                            video = DirectShowSource(""{0}"")
                            Intro(video, ""{1}"", {2})
                          ", pathToReference, pathToImage, EffectDuration);

            WriteAvsScript(context, script);
        }
Exemplo n.º 5
0
        public override void WriteToAvs(BatchCommandContext context)
        {
            var input  = GetInput(context, VideoInput);
            var prev   = Path.Combine(context.path, VideoPrev);
            var script = String.Format(@"
                            {0}
                            prev = DirectShowSource(""{1}"")
                            CrossFadeTime(video, prev, {2})
                          ", input, prev, EffectDuration);

            WriteAvsScript(context, script);
        }
Exemplo n.º 6
0
        private void WriteAvsScript(BatchCommandContext context)  // transformations to write to .AVS file
        {
            // chain transformations inside .avs script
            // return video
            // NOTE: do not rely on SourceFilename, use data supplied in AviSynthCommands!

            context.batFile.WriteLine("import(\"{0}\")", AviSynthCommand.LibraryPath);
            foreach (var t in Transformations)
            {
                t.WriteToAvs(context);
            }
        }
Exemplo n.º 7
0
        internal string GetInput(BatchCommandContext context, string videoInput)
        {
            string input;

            if (String.IsNullOrEmpty(videoInput))
            {
                input = "video = last";
            }
            else
            {
                input = String.Format(@"video = DirectShowSource(""{0}"")",
                                      Path.Combine(context.path, videoInput));
            }
            return(input);
        }
Exemplo n.º 8
0
        public override void WriteToAvs(BatchCommandContext context)
        {
            var input = GetInput(context, VideoInput);

            Settings["image"] = Path.Combine(context.path, Settings["image"]);
            var paramString = String.Join(
                ", ",
                Settings.Select(pair => String.Format(@"{0}=""{1}""", pair.Key, pair.Value))
                );
            var script = String.Format(@"
                            {0}
                            AddWatermarkPNG(video, {1})
                          ", input, paramString);

            WriteAvsScript(context, script);
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            Environment.CurrentDirectory = "..\\..\\..\\..\\Video\\TestFiles\\";
            try
            {
                Directory.CreateDirectory("Work");
            }
            catch { }
            Environment.CurrentDirectory += "\\Work\\";

            var chunks=new List<Chunk>
            {
                new Chunk
                {
                    Id = 1,
                    VideoSource = new ChunkSource { File = "..\\Original\\123-en.mp4", StartTime = 0, Duration = 1000 }
                },
                new Chunk
                {
                    Id = 2,
                    VideoSource = new ChunkSource { File = "..\\Original\\123-en.mp4", StartTime = 1000, Duration = 1000 },
                    AudioSource = new ChunkSource { File = "..\\Original\\123-fr.mp4", StartTime = 1000, Duration = 1000 }
                },
                new Chunk
                {
                    Id = 3,
                    VideoSource = new ChunkSource { File = "..\\Original\\123-en.mp4", StartTime = 2000, Duration = 1000 },
                    AudioSource = new ChunkSource { File = "..\\Original\\123-de.mp4", StartTime = 2000, Duration = 1000 }
                }
            };

            foreach (var e in Directory.GetFiles(".\\","*.mp*"))
                File.Delete(e);

            var context = new BatchCommandContext
            {
                path = "C:\\ffmpeg\\bin\\ffmpeg.exe"
            };

            foreach (var e in Montager.Processing2(chunks,"output.mp4"))
            {
                Console.ForegroundColor = ConsoleColor.DarkCyan;
                Console.WriteLine(e.Caption);
                Console.ForegroundColor = ConsoleColor.Gray;
                e.WriteToBatch(context);
            }
        }
Exemplo n.º 10
0
        public override void WriteToBatch(BatchCommandContext context)  // ffmpeg execution string for .BAT file
        {
            // open script 'AvsFilename' and produce video 'Filename'
            // take care of high and low profiles

            if (String.IsNullOrEmpty(AvsFilename))
            {
                return;
            }
            Directory.CreateDirectory(processingDir);
            var avsContext = new BatchCommandContext
            {
                batFile    = new StreamWriter(AvsFilename, false, Encoding.GetEncoding(1251)),
                path       = pathToBase,            // NOTE: not FFMPEG, actually
                lowQuality = context.lowQuality
            };

            WriteAvsScript(avsContext);
            avsContext.batFile.Close();

            // AviSynth outputs raw (?) video, so we need to recode it to match other clips' properties
            // NOTE: no need to deal with HIGH/LOW profiles for now.
            context.batFile.WriteLine("ffmpeg -i {0} -vf scale=1280:720 -r 30 -q:v 0 -acodec libmp3lame -ar 44100 -ab 32k {1}", AvsFilename, ResultFilename);
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            Environment.CurrentDirectory = "..\\..\\..\\..\\Video\\TestFiles\\";
            try
            {
                Directory.CreateDirectory("Work");
            }
            catch { }
            Environment.CurrentDirectory += "\\Work\\";


            var chunks = new List <Chunk>
            {
                new Chunk
                {
                    Id          = 1,
                    VideoSource = new ChunkSource {
                        File = "..\\Original\\123-en.mp4", StartTime = 0, Duration = 1000
                    }
                },
                new Chunk
                {
                    Id          = 2,
                    VideoSource = new ChunkSource {
                        File = "..\\Original\\123-en.mp4", StartTime = 1000, Duration = 1000
                    },
                    AudioSource = new ChunkSource {
                        File = "..\\Original\\123-fr.mp4", StartTime = 1000, Duration = 1000
                    }
                },
                new Chunk
                {
                    Id          = 3,
                    VideoSource = new ChunkSource {
                        File = "..\\Original\\123-en.mp4", StartTime = 2000, Duration = 1000
                    },
                    AudioSource = new ChunkSource {
                        File = "..\\Original\\123-de.mp4", StartTime = 2000, Duration = 1000
                    }
                }
            };

            foreach (var e in Directory.GetFiles(".\\", "*.mp*"))
            {
                File.Delete(e);
            }


            var context = new BatchCommandContext
            {
                path = "C:\\ffmpeg\\bin\\ffmpeg.exe"
            };

            foreach (var e in Montager.Processing2(chunks, "output.mp4"))
            {
                Console.ForegroundColor = ConsoleColor.DarkCyan;
                Console.WriteLine(e.Caption);
                Console.ForegroundColor = ConsoleColor.Gray;
                e.WriteToBatch(context);
            }
        }
Exemplo n.º 12
0
 internal void WriteAvsScript(BatchCommandContext avsContext, string avsScript)
 {
     avsContext.batFile.WriteLine(avsScript);
 }
Exemplo n.º 13
0
 public abstract void WriteToAvs(BatchCommandContext avsContext);