Open kobaz opened 1 year ago
If it only occurs occasionally my best guess is that because you are using Task.StartNew()
in DoRecording()
, you are using the MediaContainer instance on a different thread than it was created on; you probably have a race condition.
I recommend, instead of DoRecording()
returning void
, it should instead return a Task
that can then be awaited by the caller. You should also refactor your code so that the MediaContainer is created within that same thread at the start (i.e inside the lambda function passed to Task.StartNew()
).
Also note that conventionally, to cancel the running recording task, you would use a CancellationToken passed as a parameter to the asynchronous method.
See this page for official Microsoft documentation on how to properly use the .NET Task Parallel Library.
Good luck, and feel free to send the bounty reward my way if this was at all helpful. My PayPal is donate@chosenfewsoftware.com
Howdy @IsaMorphic,
This was not the issue, but also thanks for the suggestions. I'll send you something for your time.
The cause of the problem was having a height component of the screen resolution that was not divisible by 2 (Happens if you're in a remote desktop session with dynamic sizing enabled.. so you could in theory have a resolution height like 1235)
I found the issue with doing some extensive research on how to get the low level debug logs from ffmpeg. I'll post them up here for future reference. This whole 'Generic Error' popping up with absolutely no other information made this a hard problem to find.
Thanks for updating me, and you're welcome! I thought this could also be an issue but it relied on an assumption on my part about how your application functioned. I appreciate the money-stuffs, too :D
Getting this randomly. Perhaps some sort of resource issue? It works fine for a while and then stops working.
Here's how it's being used: