Page 1 of 1

Playing RawData using aforge.net

PostPosted: Wed Nov 13, 2019 6:42 am
by DSZ
Using AForge.Video I can paly webcam live videos. My doubt is, can I play raw data or locally stored mp4 videos using same frame work. if yes, please give an example. I could not find. Instead can see samples using VideoFileSource of Accord.net .

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()

Re: Playing RawData using aforge.net

PostPosted: Wed Nov 13, 2019 9:02 am
by andrew.kirillov
Check AForge.Video.FFMPEG namespace. Accord.NET just took it from there.

DSZ wrote: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)'

You need to make sure all DLLs of FFmpeg library are there with your executable.

Re: Playing RawData using aforge.net

PostPosted: Tue Nov 19, 2019 11:14 am
by DSZ
Yes using libraries as listed in above link.
here is the screen shots for packages i'm using.
I got same exception when loading the video.
Please help to correct

Re: Playing RawData using aforge.net

PostPosted: Tue Nov 19, 2019 12:07 pm
by andrew.kirillov
Also make sure you build your .NET application for 32-bit target - same FFmpeg DLLs are targeted for.

Re: Playing RawData using aforge.net

PostPosted: Wed Nov 20, 2019 5:26 am
by DSZ
Facing same issue on 32 bit target