mmozeiko / wcap

Small and efficient screen recording utility for Windows 10 and 11
The Unlicense
841 stars 35 forks source link

It only records one second of video #22

Closed SanJacobs closed 1 year ago

SanJacobs commented 1 year ago

99% of the time, wcap only records about a second of video. I have not been able to reliably reproduce the 1% of the time where it records until I tell it to stop. On rare occasion, it happens once if I change the settings back and fourth for a bit, and then goes back to only recording one second.

While recording, it displays the yellow borders as though it is still recording, but the stored file will be 100-600 KB and no longer than 1-2 seconds.

Sorry that this bug report is a little vague, but this is all I know right now. Please tell me if there's anything more I can do to help solve this, because it makes wcap completely unusable for me.

https://github.com/mmozeiko/wcap/assets/21090839/84b54752-77e1-48f6-8f36-f32c06ca27ef

https://github.com/mmozeiko/wcap/assets/21090839/e80ea864-9152-4ab6-90cf-787162419ee3

https://github.com/mmozeiko/wcap/assets/21090839/19440acd-d606-44ac-a3ee-e0ed89fd1e38

I'm on W10, btw.

SanJacobs commented 1 year ago

Same thing happens when doing a fragmented MP4.

https://github.com/mmozeiko/wcap/assets/21090839/e16187b2-d3ba-4423-9ccf-ebd348b8efdb

mmozeiko commented 1 year ago

These videos are encoded using Microsoft CPU encoder. Have you tried enabling GPU Encoder setting? What is your GPU? Make sure you have up to date drivers, as they often fix issues related to video encoding.

Also check that you don't have Limit Length or Limit Size checkboxes set - they explicitly limit size/length for video file.

SanJacobs commented 1 year ago

I have not set any limits. Though sometimes setting a limit will let me record for longer for a while before the problem comes back, and sometimes removing the limit again afterwards does the same thing.

Same issue happens when I switch to "Prefer dGPU". After changing the setting, it works for a little bit, just like with changing almost any of the settings, but some time later, same thing happens.

https://github.com/mmozeiko/wcap/assets/21090839/1051fbeb-fc61-4b7f-a3ed-88b964edb355

I'm running a RTX 2070 (non-super), and this happened on driver verison 516.94, which is from 2022-08-09. I have updated now, and the issue seems resolved at the very moment, but I will give it some time and see if it returns again randomly.

SanJacobs commented 1 year ago

Well, that didn't take long. This is on version 537.13 from 2023-08-22.

https://github.com/mmozeiko/wcap/assets/21090839/67154835-1ae0-42ae-9dd0-522e89c4b639

mmozeiko commented 1 year ago

What happens if you disable audio capture in settings. Do the video recording only. Just to eliminate possibility that ther's something wrong with audio capture.

SanJacobs commented 1 year ago

Disabling the audio does seem to fix it. Maybe it'll break again at some point, but I think this might be it, because if I switch back it consistently breaks again. Most of the time when it got better from just changing random settings, it would still be ok if I changed back, this time it's not like that.

https://github.com/mmozeiko/wcap/assets/21090839/8b0a80e0-7c58-47be-ae77-d651fd7c7330

SanJacobs commented 1 year ago

Can confirm, it's been stable for days now after disabling the audio recording. Not very helpful for me, though, since I mostly use it in my work as a sound designer, hahaha.

mmozeiko commented 1 year ago

Could you compile wcap and run it in a debugger?

I'm not sure why it is stopping. I would be interested in seeing call-stack when you put breakpoint on this line and then make it to record with audio enabled (and then wait when it stops after 1 second of recording): https://github.com/mmozeiko/wcap/blob/main/wcap.c#L317

And also probably see call-stack when breakpoints are set here: https://github.com/mmozeiko/wcap/blob/main/wcap.c#L1159 https://github.com/mmozeiko/wcap/blob/main/wcap.c#L1217

SanJacobs commented 1 year ago

I would be happy to.

L317

image

Maybe I'm using the debugger wrong, but it never hit the breakpoints at 1159 or 1217?

I have found a condition that consistently breaks it, and that is if my output audio device is "Oculus Viritual Audio Device" for my Meta Quest 2. I'm not sure why this happens now, because I tried eliminating that as a potential cause earlier, that's why I had written "disconnected" in the notepad window, because I had disconnected and deselected it as my audio output when testing.

There were also plenty of days where I wouldn't have used that output, because I didn't use my Quest, and it still broke, so I don't think this is the only condition that can cause it, but at least we have one we can test with.

By the way, I am on the HMN Discord, if you think debugging something like this would be better done "live".

mmozeiko commented 1 year ago

Fixed in 8c4655db928dc31aa7253fe8715ee3a195d52c88

Turns out some WASAPI devices give really bad device timestamps for captured audio. In this case they were >200hours off the expected values. That's why mp4 Media Foundation encoder was not writing any new video frames - it was waiting for all those 200+ hours of audio before continuing.

Similar issue is reported in Chromium here: http://crbug.com/1439283

If somebody wants to read debugging discussion: https://discord.com/channels/239737791225790464/1152686969579655269