Example #1
0
        static void Main()
        {
           //var reader = new CameraCapture(0); //capture from camera
           var reader = new FileCapture(Path.Combine(getResourceDir(), "Welcome.mp4"));
           reader.Open();

           var writer = new VideoWriter(@"output.avi", reader.FrameSize, /*reader.FrameRate does not work Cameras*/ 30); //TODO: bug: FPS does not work for cameras
           writer.Open();

            Bgr<byte>[,] frame = null;
            do
            {
                reader.ReadTo(ref frame);
                if (frame == null)
                    break;

                using (var uFrame = frame.Lock())
                { writer.Write(uFrame); }

                frame.Show(scaleForm: true);
            }
            while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape));

            reader.Dispose();
            writer.Dispose();

            UI.CloseAll();
        }
Example #2
0
        public static void Main()
        {
            //var pipeName = new Uri("http://trailers.divx.com/divx_prod/divx_plus_hd_showcase/BigBuckBunny_DivX_HD720p_ASP.divx").NamedPipeFromVideoUri(); //web-video
            var pipeName = new Uri("https://www.youtube.com/watch?v=Vpg9yizPP_g").NamedPipeFromYoutubeUri(); //Youtube

            ImageStreamReader reader = new FileCapture(String.Format(@"\\.\pipe\{0}", pipeName));
            reader.Open();

            Bgr<byte>[,] frame = null;
            do
            {
                reader.ReadTo(ref frame);
                if (frame == null)
                    break;

                frame.Show(scaleForm: true);
                ((double)reader.Position / reader.Length).Progress();
            }
            while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape));

            Console.WriteLine("The end.");

            //---------------------------------------------------------------------------
            Console.WriteLine("Downloading video...");

            string fileExtension;
            pipeName = new Uri("https://www.youtube.com/watch?v=Vpg9yizPP_g").NamedPipeFromYoutubeUri(out fileExtension); //Youtube

            pipeName.SaveNamedPipeStream("out" + fileExtension);
            Console.WriteLine("Video saved.");
        }
Example #3
0
        private static void extractVideo(string fileName)
        {
            //get output dir (same as file name and in the same folder as video)
            var fileInfo = new FileInfo(fileName);
            var fileNameNoExt = fileInfo.Name.Replace(fileInfo.Extension, String.Empty);
            string outputDir = Path.Combine(fileInfo.DirectoryName, fileNameNoExt);

            //open video
            var reader = new FileCapture(fileName);
            reader.Open();

            reader.SaveFrames(outputDir, "{0}.jpg", (percentage) =>
            {
                ((double)percentage).Progress(message: "Extracting " + fileNameNoExt);
            });

            UI.CloseAll();
        }
Example #4
0
        private static void extractVideo(string fileName)
        {
            //get output dir (same as file name and in the same folder as video)
            var fileInfo = new FileInfo(fileName);
            var fileNameNoExt = fileInfo.Name.Replace(fileInfo.Extension, String.Empty);
            string outputDir = Path.Combine(fileInfo.DirectoryName, fileNameNoExt);

            //open video
            var reader = new FileCapture(fileName);
            reader.Open();

            Console.WriteLine("Extracting video frames - {0}...", fileNameNoExt);

            reader.SaveFrames(outputDir, "{0}.jpg", (percentage) =>
            {
                Console.Write("\r Completed: {0} %", (int)(percentage * 100));
            });

            Console.WriteLine();
        }