sskodje / ScreenRecorderLib

A .NET library for screen recording in Windows, using native Microsoft Media Foundation for realtime encoding to h264 video or PNG images.
MIT License
414 stars 94 forks source link

Failed to initialize video sink writer : The data specified for the media type is invalid, inconsistent, or not supported by this object. #275

Closed JanssonTheBest closed 1 month ago

JanssonTheBest commented 11 months ago

I switched to H265 encoder in my code but now suddenly I get an error.

Failed to initialize video sink writer : The data specified for the media type is invalid, inconsistent, or not supported by this object.

sskodje commented 11 months ago

Does the computer have H265 encoding capability? This usually either comes from hardware encoders on a modern-ish graphics card, or from installing the HEVC Video Extensions on Microsoft Store.

linuxakros commented 11 months ago

Same error (in French = text in first post):

2023-12-08 20:59:05.147 [DEBUG] [RecordingManager.cpp | ConfigureOutputDir: 144] >> Video output folder is ready 2023-12-08 20:59:05.150 [DEBUG] [RecordingManager.cpp | ConfigureOutputDir: 173] >> Snapshot output folder is ready 2023-12-08 20:59:05.151 [INFO] [RecordingManager.cpp | operator (): 279] >> Starting recording task 2023-12-08 20:59:05.200 [INFO] [MouseManager.cpp | InitializeMouseClic: 161] >> Created mouse click detection hook 2023-12-08 20:59:05.232 [ERROR] [OutputManager.cpp | InitializeVideoSink: 461] >> RETURN_ON_BAD_HR: hr=0xc00d36b4, error is: Les données spécifiées pour le type de média ne sont pas valides, sont incohérentes ou ne sont pas prises en charge par cet objet. 2023-12-08 20:59:05.233 [ERROR] [OutputManager.cpp | BeginRecording: 100] >> RETURN_ON_BAD_HR: hr=0xc00d36b4, error is: Les données spécifiées pour le type de média ne sont pas valides, sont incohérentes ou ne sont pas prises en charge par cet objet. 2023-12-08 20:59:05.234 [ERROR] [RecordingManager.cpp | StartRecorderLoop: 479] >> RETURN_RESULT_ON_BAD_HR: hr=0xc00d36b4, error is: Les données spécifiées pour le type de média ne sont pas valides, sont incohérentes ou ne sont pas prises en charge par cet objet. 2023-12-08 20:59:05.237 [INFO] [OutputManager.cpp | FinalizeRecording: 133] >> Cleaning up resources 2023-12-08 20:59:05.238 [INFO] [OutputManager.cpp | FinalizeRecording: 134] >> Finalizing recording

JanssonTheBest commented 11 months ago

Does the computer have H265 encoding capability? This usually either comes from hardware encoders on a modern-ish graphics card, or from installing the HEVC Video Extensions on Microsoft Store.

Is there a way I could garant this within the program, like a nuget package? Or is it because you use windows media foundation?

sskodje commented 11 months ago

Unfortunately not to my knowledge, the only guarantee is that H264 is available in Windows. Yes, it's because this library relies on Media Foundation to supply the codecs.

JanssonTheBest commented 11 months ago

Unfortunately not to my knowledge, the only guarantee is that H264 is available in Windows. Yes, it's because this library relies on Media Foundation to supply the codecs.

What folder does windows media foundation search for codecs?

JanssonTheBest commented 11 months ago

Installed an extenstion still a problem, could it be due to a unactivated windows?