예제 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to EASY ANIMATION COMPOSER");
            if (args.Length > 0)
            {
                ConsoleMode = true;
            }
            if (ConsoleMode)
            {
                RunConsole(args);
            }
            else
            {
                Console.WriteLine("You can also run program with arguments: eacomposer [name] [path-to-dir-with-images] [FPS]");
                args = new string[3];
                Console.WriteLine("Write project name: ");
                args[0] = Console.ReadLine();
                Console.WriteLine("Write directory name: ");
                args[1] = Console.ReadLine();
                Console.WriteLine("Write FPS (15 by default): ");
                string tmp = Console.ReadLine();
                if (string.IsNullOrEmpty(tmp))
                {
                    args[2] = "15";
                }
                else
                {
                    args[2] = tmp;
                }

                RunConsole(args);
            }
            fps += fps / 10;
            FFMpegOptions.Configure(new FFMpegOptions {
                RootDirectory = AppContext.BaseDirectory + @"\bin"
            });
            Console.WriteLine($"Working on project {name}");
            Console.WriteLine($"Step 1: Add images ({img_paths.Capacity})");
            ImageInfo[] frames = new ImageInfo[img_paths.Capacity];
            for (int i = 0; i < img_paths.Capacity; i++)
            {
                Console.Write('.');
                frames[i] = new ImageInfo(img_paths[i]);
            }

            path += "/" + name + ".mp4";
            if (File.Exists(path))
            {
                new FileInfo(path).Delete();
            }
            Console.WriteLine();
            Console.WriteLine($"Step 2: Creating video on path {path}");

            FFMpeg encoder = new FFMpeg();

            encoder.JoinImageSequence(new FileInfo(path), fps, frames);

            Console.WriteLine($"Finished!");
            encoder.Dispose();
        }