Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var paramsControl = new ParamsControl<CommandLineParamsOptions>(new CommandLineParamsOptions(), args, "Thumbnail extractor");
            var valid = paramsControl.Validate();
            if (valid == false)
            {
                Console.WriteLine(paramsControl.GenerateError());
                return;
            }
            FileAttributes sourceAttributes = FileAttributes.Normal;
            try
            {
                sourceAttributes = File.GetAttributes(paramsControl.Values.Source);
            }
            catch(Exception ex)
            {
                Console.WriteLine("Failed to get the file: " + ex.ToString());
                return;
            }
            IEnumerable<string> videosToProcess = null;
            if(sourceAttributes.HasFlag(FileAttributes.Directory))
            {
                videosToProcess = Directory.GetFiles(paramsControl.Values.Source, "*m.mp4", SearchOption.AllDirectories);
            }
            else
            {
                videosToProcess = new string [] { paramsControl.Values.Source };
            }
            foreach(var videoPath in videosToProcess)
            {
                string rawOutFile = ExtractFrameToFile(paramsControl, videoPath);
                if (File.Exists(rawOutFile))
                {
                    var outFile = GetThumbName(rawOutFile, "play_", ".jpg");
                    Bitmap raw = new Bitmap(rawOutFile);
                    raw.CropImage()
                        .FilterEdge()
                        //.ToBlackAndWhite()
                        .Negative()
                        .Resize(paramsControl.Values.HeightOfTheOutputInPixels)
                        .AddPlayOverlay()
                        .Save(outFile);
                }
            }

            Console.WriteLine("Done");
        }
Exemplo n.º 2
0
 private static string ExtractFrameToFile(ParamsControl<CommandLineParamsOptions> paramsControl, string videoPath)
 {
     var rawOutFile = GetThumbName(videoPath, "thumb_", ".jpg");
     ExtractFrame(videoPath, paramsControl.Values.TimeFrameInSeconds, rawOutFile);
     return rawOutFile;
 }