unosquare / ffmediaelement

FFME: The Advanced WPF MediaElement (based on FFmpeg)
https://unosquare.github.io/ffmediaelement/
Other
1.17k stars 240 forks source link

Extremely High CPU usage when seeking quickly #451

Closed abbrima closed 4 years ago

abbrima commented 4 years ago

Extremely High CPU usage when seeking quickly

I'm writing an application that includes a video player (ffme) which must synchronize with another application using MIDI Timecode. These MIDI messages control the position of the player. When seeking from an external application, these Timecodes are sent very fast and the result is the Seek Method being called many times quickly. This is resulting in 65-70% cpu usage and my other application to crash due to that cpu usage. Debugging the application showed that most of the usage was due to avcodec-58.dll

Note: These Timecodes are in sequence. Note: Library.EnableWpfMultiThreadedVideo = true;

Issue Categories

Version Information

Steps to Reproduce

  1. Load a video.
  2. Call the Seek(TimeSpan span) method very fast

Expected Results

Sample Code

C

 public static void Seek(mTimecode timecode)
        {
            if (!Video.HasVideo)
            {
                return;
            }
            TimeSpan time_playest = timecode.GetSpan();                
            Video.Seek(time_playest);
        }
abbrima commented 4 years ago

I used Hardware accelration and it solved everything !