コード例 #1
0
        public void ReadFromVideo(string path)
        {
            pathToFile = new Uri(AnaglyphParameters.VideoPath.LocalPath);
            AnaglyphParameters.PathToRead  = pathToFile.LocalPath;
            AnaglyphParameters.PathToWrite = path.Split('.')[0] + "1.mp4";
            reader.Open(pathToFile.LocalPath);

            SetWriter(reader, writer);


            for (int i = 0; i < reader.FrameCount; i++)
            {
                OnOnFrameDone(i, (int)reader.FrameCount);
                try
                {
                    using (Bitmap videoFrame = reader.ReadVideoFrame(i))
                    {
                        using (Bitmap videoFrameChanged = new Fitler().Calc(videoFrame))
                        {
                            writer.WriteVideoFrame(videoFrameChanged, (uint)i);
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                }
            }
            reader.Close();
            writer.Close();

            VideoToFrames.AddAudioToVideo(path);
            OnOnProcessDone();
        }
コード例 #2
0
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundHelperRequest argmunets = (BackgroundHelperRequest)e.Argument;


            //Call Algorithm
            Bitmap newImage = new Fitler().Calc(argmunets.Image);

            e.Result = new BackgroundHelperResponse
            {
                Image    = newImage,
                Location = "",
            };
        }
コード例 #3
0
        public void ReadFromVideoSample(string path, double curentTime, String numberOfFrames, bool includeAudio)
        {
            int number = 0;

            if (numberOfFrames != "")
            {
                number = Convert.ToInt32(numberOfFrames);
            }
            pathToFile = new Uri(AnaglyphParameters.VideoPath.LocalPath);
            reader.Open(pathToFile.LocalPath);
            int startingFrame = Convert.ToInt32(curentTime * reader.FrameRate.Value);
            int endingFrame   = Convert.ToInt32(startingFrame + number);

            AnaglyphParameters.PathToRead  = pathToFile.LocalPath;
            AnaglyphParameters.PathToWrite = path.Split('.')[0] + "1.mp4";// pathToFile.LocalPath.Split('.')[0] + "1.mp4";
            reader.Open(pathToFile.LocalPath);
            SetWriter(reader, writer);
            int j = 0;

            for (int i = startingFrame; i < endingFrame; i++)
            {
                OnOnFrameDone(j, number);
                try
                {
                    using (Bitmap videoFrame = reader.ReadVideoFrame(i))
                    {
                        using (Bitmap videoFrameChanged = new Fitler().Calc(videoFrame))
                        {
                            writer.WriteVideoFrame(videoFrameChanged, (uint)i);

                            videoFrameChanged.Dispose();
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                }

                j++;
            }
            reader.Close();
            writer.Close();
            //string metadata = GetMetadataFromVideo(AnaglyphParameters.PathToRead);

            OnOnProcessDone();
        }