Below code is for playing usb web cam
- Code: Select all
VideoSourcePlayer Player = new VideoSourcePlayer();
VideoCaptureDevice videoSource1 = new VideoCaptureDevice(SelectedCamDetails);
Player.VideoSource = videoSource1;
Player.NewFrame += new AForge.Controls.VideoSourcePlayer.NewFrameHandler(this.videoSourcePlayer1_NewFrame);
Player.Start();
Below code is for playing local video using accord.net. But it gets slow for high HD videos
- Code: Select all
using Accord.Video.FFMPEG;
VideoFileSource VideoFileSource1= new VideoFileSource(BrowseVideoFileName1);
// set NewFrame event handler
VideoFileSource1.NewFrame += new Accord.Video.NewFrameEventHandler(videoFileSource1_NewFrame);
VideoFileSource1.Start();
private void videoFileSource1_NewFrame(object sender, Accord.Video.NewFrameEventArgs eventArgs)
{
Bitmap image = new Bitmap(eventArgs.Frame);
pictureBox1.Image = image;
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
}
when trying with aforge player as below , it throw exception
System.IO.FileLoadException: 'Could not load file or assembly 'AForge.Video.FFMPEG, Version=2.2.5.0, Culture=neutral, PublicKeyToken=03563089b1be05dd' or one of its dependencies. Attempt to load an unverifiable executable with fixups (IAT with more than 2 sections or a TLS section.) (Exception from HRESULT: 0x80131019)'
- Code: Select all
using AForge.Video.FFMPEG;
VideoSourcePlayer Player = new VideoSourcePlayer();
string BrowseVideoFileName1 = MultiCamSelection.BrowseVideoFileName1;
VideoFileSource1 = new VideoFileSource(BrowseVideoFileName1);
Player.VideoSource = VideoFileSource1;
Player.NewFrame += new VideoSourcePlayer.NewFrameHandler(videoFileSourcee_NewFrame);
Player.Start()