AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

100% CPU usage

Forum to discuss AForge.NET Framework, its features, API, how-tos, etc.

100% CPU usage

Postby e.preto » Tue Feb 27, 2018 11:49 am

Hello,

I'm running a simple program for record (using FFMPEG H264 compress) and preview - a 1920x1080 aprox. 50FPS capture device - and i'm constantly getting 100 % of the cpu. I already tested on other pc (not MAC) and same result. Is it normal ?! This is a problem because, when 100% of usage the program drop frames, because it can't handle more..

My specs:

MacBook Pro Early 2015 (native Windows installed)
Intel Core i5 dual-core 2,7 GHz

My Code:

Code: Select all

(...)
// start camera and preview
VideoCaptureDevice videoSourceEndo = new VideoCaptureDevice(videoDevices[cb_endo.SelectedIndex].MonikerString);
AsyncVideoSource asyncVideoSourceEndo = new AsyncVideoSource(videoSourceEndo);
asyncVideoSourceEndo.SkipFramesIfBusy = false;

videoSourcePlayer1.VideoSource = asyncVideoSourceEndo;
videoSourcePlayer1.Start();

videoSourceEndo.NewFrame += VideoSourceEndo_NewFrame;

(...)
private void VideoSourceEndo_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            if (isRecording && writer1 != null && writer1.IsOpen)
            {
                Bitmap bitmap = (Bitmap)eventArgs.Frame.Clone();
                writer1.WriteVideoFrame(bitmap);
                bitmap.Dispose();
            }
        }
e.preto
 
Posts: 6
Joined: Thu Feb 15, 2018 6:55 pm

Re: 100% CPU usage

Postby andrew.kirillov » Tue Feb 27, 2018 12:28 pm

Hello,

AForge.NET Framework uses FFmpeg library for saving video. So it is that component which must be troubleshooted.

Any way, 100% CPU usage does not sound too wrong for encoding video at 1920x1080@50fps .
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3298
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: 100% CPU usage

Postby e.preto » Tue Feb 27, 2018 6:17 pm

Thanks for awnsering my question..

Is there any way of boost the processing without a better CPU? (use integrated GPU or something...)
e.preto
 
Posts: 6
Joined: Thu Feb 15, 2018 6:55 pm

Re: 100% CPU usage

Postby andrew.kirillov » Tue Feb 27, 2018 9:51 pm

Check with FFmpeg, which hadnles video saving.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3298
Joined: Fri Jan 23, 2009 9:12 am
Location: UK




Return to AForge.NET Framework

cron