ScreenRecorderLib icon indicating copy to clipboard operation
ScreenRecorderLib copied to clipboard

Capture duration incorrect for fragmented recording when CPU is high

Open mmhmmh opened this issue 2 years ago • 4 comments

Hi,

This is a very useful library. Thanks to all who contributed.

While testing, I did find a weird issue when the fragmented recording option is turned on.

Basically if for any reason the capture loop is not at the specified framerate, the total duration will drift shorter resulting in sync issues.

One way to reproduce is to start the capture and then ran a CPU stress tool and capture exactly 5 mins of the desktop. You will see that the result video duration, when opened in the VLC, will say exactly 5 min, but when dragged to chrome web browser it will say something like 4:45 so about 15s short.

This behavior does not appear if the fragmented option is off.

I dumped the frames of the video and confirmed that the duration is indeed short.

I looked at the code and it looks like it is just using the MFCreateFMPEG4MediaSink instead of MFCreateMPEG4MediaSink so I have no clue how the behavior is different.

Can anyone share some insight on how to approach debugging this issue?

mmhmmh avatar Sep 20 '21 15:09 mmhmmh

It only happens when you stress the cpu? Do you use gpu or cpu encoding?

sskodje avatar Sep 22 '21 18:09 sskodje

I have only tested stressing the CPU because that's the most common scenario. It is using GPU accelerated encoding.

mmhmmh avatar Sep 23 '21 19:09 mmhmmh

@sskodje Hi, just wondering if you were able to reproduce this issue.

mmhmmh avatar Nov 30 '21 19:11 mmhmmh

Unfortunately i have not had any time to investigate it, as i've spent the time i have trying to get the next release out. Can you check if the issue is still present in this version?

https://github.com/sskodje/ScreenRecorderLib/actions/runs/1478803218

sskodje avatar Dec 02 '21 13:12 sskodje