static void Main(string[] args)
        {
            var options = new PicToAsciiOptions()
            {
                FixedDimension    = PicToAsciiOptions.Fix.Vertical,
                FixedSize         = 54,
                SymbolAspectRatio = 7f / 12f,
                AsciiTable        = PicToAsciiOptions.ASCIITABLE_SYMBOLIC_LIGHT
            };

            pic2ascii = new PicToAscii(options);

            font = new Font("Lucida Console", 12, FontStyle.Regular, GraphicsUnit.Pixel);

            writer = new VideoFileWriter( );
            writer.Open($"{MOV_PATH}~test.avi", width, height, 30, VideoCodec.MPEG4, 6000000);

            VideoFileSource videoSource = new VideoFileSource(MOVIESAMPLE_PATH);

            videoSource.NewFrame        += VideoSource_NewFrame;
            videoSource.PlayingFinished += VideoSource_PlayingFinished;
            videoSource.Start();

            Console.ReadLine();
            if (videoSource.IsRunning)
            {
                videoSource.SignalToStop();
                Console.ReadLine();
            }
        }
예제 #2
0
 /// <summary>
 /// This event is called when the stream finishes and loopAudio is set to true.
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="reason"></param>
 public void PlayingFinished(object sender, ReasonToFinishPlaying reason)
 {
     _source                  = new VideoFileSource(_source.Source);
     _source.NewFrame        += NextFrame;
     _source.PlayingFinished += PlayingFinished;
     _source.Start();
 }
예제 #3
0
 public VideoStreamImp(VideoFileSource source, bool loopVideo, bool useAudio)
 {
     _source           = source;
     _source.NewFrame += NextFrame;
     if (loopVideo)
     {
         _source.PlayingFinished += PlayingFinished;
     }
     _source.VideoSourceError += VideoSourceError;
     _source.WaitForStop();
     _source.Start();
 }
예제 #4
0
파일: Form1.cs 프로젝트: Ponita48/Tugas
        private void button4_Click(object sender, EventArgs e)
        {
            OpenFileDialog of = new OpenFileDialog();

            //For any other formats
            if (of.ShowDialog() == DialogResult.OK)
            {
                baca           = new VideoFileSource(of.FileName);
                baca.NewFrame += stream_NewFrame;
                baca.Start();
            }
        }
예제 #5
0
        private void openvideo_Click_1(object sender, EventArgs e)
        {
            OpenFileDialog Dialog = new OpenFileDialog();

            if (Dialog.ShowDialog() == DialogResult.OK)
            {
                videoSource = new VideoFileSource(Dialog.FileName);
                // set NewFrame event handler
                videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
                // start the video source
                videoSource.Start();
            }
        }
예제 #6
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (button3.Text == "Stop Video")
     {
         videoSource.SignalToStop();
         button3.Text = "Start Video";
     }
     else if (button3.Text == "Start Video")
     {
         videoSource.Start();
         button3.Text = "Stop Video";
     }
 }
예제 #7
0
파일: Form1.cs 프로젝트: Ponita48/Tugas
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog of = new OpenFileDialog();

            //For any other formats
            if (kamera != null && kamera.IsRunning)
            {
                kamera.Stop();
            }
            if (of.ShowDialog() == DialogResult.OK)
            {
                baca           = new VideoFileSource(of.FileName);
                baca.NewFrame += new NewFrameEventHandler(kamera_ProsesFrame);
                baca.Start();
            }
        }
예제 #8
0
        private void startButton_Click(object sender, EventArgs e)
        {
            if (((Button)sender).Text == "Start")
            {
                if (FinalFrame != null)
                {
                    videoSourcePlayer.SignalToStop();
                }
                startButton.Text = "Stop";

                if (cbListDevices.SelectedIndex == cbListDevices.Items.Count - 1) // browse
                {
                    pictureBox1.BringToFront();
                    if (videoSourcePlayer.IsRunning)
                    {
                        videoSourcePlayer.Stop();
                    }
                    videoSource2           = new VideoFileSource(filePath);
                    videoSource2.NewFrame += new Accord.Video.NewFrameEventHandler(video_NewFrame);
                    // start the video source (local video)
                    videoSource2.Start();
                }
                else
                {
                    if (videoSource2 != null)
                    {
                        videoSource2.SignalToStop();
                    }
                    videoSourcePlayer.BringToFront();
                    FinalFrame = new VideoCaptureDevice(videoSource[cbListDevices.SelectedIndex].MonikerString);
                    //videoSourcePlayer.NewFrame += new VideoSourcePlayer.NewFrameHandler(this.videoSourcePlayer_NewFrame);
                    videoSourcePlayer.VideoSource = FinalFrame;
                    videoSourcePlayer.Start();
                }
            }
            else   // stop
            {
                videoSourcePlayer.SignalToStop();
                //videoSourcePlayer.SignalToStop();
                if (videoSource2 != null)
                {
                    videoSource2.SignalToStop();
                }
                ((Button)sender).Text = "Start";
            }
        }
예제 #9
0
        private void browseVid_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog
            {
                Filter = "AVI Video (*.avi, *.mp4)|*avi; *mp4"
            };

            if (open.ShowDialog() == DialogResult.OK)
            {
                // create video source
                videoSource = new VideoFileSource(open.FileName);
                // set NewFrame event handler
                videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
                // start the video source
                videoSource.Start();
                // ...
                button3.Text = "Stop Video";
            }
        }
예제 #10
0
 /// <summary>
 /// Starts the video playback.
 /// </summary>
 public void Start()
 {
     _source.Start();
 }
예제 #11
0
        private void buttonStart_Click(object sender, EventArgs e)
        {
            this.Running = true;
            try
            {
                _frameController.Start();

                if (checkBoxUseWebcam.Checked)
                {
                    // List all available video sources. (That can be webcams as well as tv cards, etc)
                    FilterInfoCollection videosources = new FilterInfoCollection(FilterCategory.VideoInputDevice);

                    //Check if atleast one video source is available
                    if (videosources != null)
                    {
                        //For example use first video device. You may check if this is your webcam.
                        VideoCaptureDevice webcam = new VideoCaptureDevice(videosources[0].MonikerString);
                        _videoSource = webcam;

                        try
                        {
                            //Check if the video device provides a list of supported resolutions
                            if (webcam.VideoCapabilities.Length > 0)
                            {
                                string highestSolution = "0;0";
                                //Search for the highest resolution
                                for (int i = 0; i < webcam.VideoCapabilities.Length; i++)
                                {
                                    if (webcam.VideoCapabilities[i].FrameSize.Width > Convert.ToInt32(highestSolution.Split(';')[0]))
                                    {
                                        highestSolution = webcam.VideoCapabilities[i].FrameSize.Width.ToString() + ";" + i.ToString();
                                    }
                                }
                                //Set the highest resolution as active
                                webcam.VideoResolution = webcam.VideoCapabilities[Convert.ToInt32(highestSolution.Split(';')[1])];
                            }
                        }
                        catch { }

                        //handle new frame event
                        webcam.NewFrame += new AForge.Video.NewFrameEventHandler(videoSource_NewFrame);

                        //Start recording
                        webcam.Start();

                        this.Resolution = $"({webcam.VideoResolution.FrameSize.Width}x{webcam.VideoResolution.FrameSize.Height})";
                        this.Log("Video capture started");
                    }
                }
                else if (!string.IsNullOrEmpty(textBoxVideoPath.Text))
                {
                    // let's process the video file
                    _videoFileSource           = new VideoFileSource(textBoxVideoPath.Text);
                    _videoFileSource.NewFrame += _videoFileSource_NewFrame;
                    // start the video source
                    _videoFileSource.Start();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                this.Running = false;
            }
            this.UpdateView(this);
        }