ffmpeg COM must not be in STA mode Calling CoUninitialize(); before avcodec_open2 prevents the error. But that does not seem to be a good solution. CoUninitialize();