ffmpeg-libav-tutorial
ffmpeg-libav-tutorial copied to clipboard
"COM must not be in STA mode\n"
Hi
This error occures when calling avcodec_open2
with the AV_CODEC_ID_H265
or AV_CODEC_ID_H264
encoder on windows:
"COM must not be in STA mode\n"
Could not open the codec: "Invalid argument"
Does anyone have an idea how to fix this?
Did you found the reason or a solution ?
Calling CoUninitialize();
before avcodec_open2
prevents the error. But that does not seem to be a good solution.
It seems to only happen when using the default encoder, not when using nvenc or x264 Calling ::CoInitialize(nullptr); or ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED) seems to solve this issue