So I am building OpenCV (4.6.0) from sources on Windows (using CMake). I’ve selected WITH_FFMPEG and OPENCV_ENABLE_NONFREE. However, I am unable to write video in h265. I’ve searched every possible answer to this problem on forums. Here is what I am getting for the below code:
[hevc_mf @ 000002583f4940c0] could not find any MFT for the given media type
[hevc_mf @ 000002583f4940c0] could not create MFT
[ERROR:firstname.lastname@example.org] global /build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp (3001) open Could not open codec hevc_mf, error: Unspecified error (-40)
VideoCaptureAPIs is just an enum declaring a backend. backends may be read-only (e.g. V4L), write-only (I don’t know), or can do both (ffmpeg)
MSMF is windows-only in any case. the MSMF API itself can be used to write video files but I don’t know if the plumbing is in OpenCV to use it for that.
to get HEVC (x265) support into ffmpeg, you’ll have to download the binaries (must contain libraries and shared objects/dlls, not just CLI programs) that come with the codec (there are “free” builds that don’t) and then figure out how to make OpenCV’s cmake stage pick them up. I’ve never done that but I hear others have. it requires setting some cmake variables to the right paths.
Thank you, documentation is a bit misleading at least for me because I thought that MSMF can be used only with video capture, but in fact OpenCV falls back to it (on my machine) when initializing video writer for ffmpeg not worked.