添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Hi guys,

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:

video_writer = cv2.VideoWriter('some_video.mp4', cv2.VideoWriter_fourcc('h','e','v','1'), fps, frame_size)

[hevc_mf @ 000002583f4940c0] could not find any MFT for the given media type
[hevc_mf @ 000002583f4940c0] could not create MFT
[ERROR:[email protected]] global /build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp (3001) open Could not open codec hevc_mf, error: Unspecified error (-40)

Has anyone had success with this?

Adding HEVC/H265 FourCC support to MSMF video writer. I have verified it with my

Sorry @berak I’ve confused your name with the contributor :sweat_smile:
You are mentioning pre-build opencv_ffmpeg dll … but I think when I build OpenCV from sources it also builds ffmpeg?

So in other words, the only thing that I need to do is to rebuild OpenCV with latest changes? Let me know if that is the thing and I will test it and report back.

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.

crackwitz:

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.

This works for me.

Error: 'Your platform doesn't suppport hardware accelerated AV1 decoding.' when i use 'cv2.VideoCapture' Python To build against FFmpeg and get AV1 decoding you need to: Build or dowload and extract a build of FFMpeg to <FFMPEG_BUILD>. I would suggest simply downloading from here and depending on your license requirements you will want to download either ffmpeg-n5.0.1-7-g7389a49fd3-win64-gpl-shared-5.0.zip ffmpeg-n5.0.1-7-g7389a49fd3-win64-lgpl-shared-5.0.zip Create a cmake directory <FFMPEG_BUILD>/cmake. Save the cmake script (ffmpeg-config.cmake) mentioned in the below post to that directory… crackwitz:

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.

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.