From cb7fe597a5f1424bb1f7f6b17d2d2a2d502aba2c Mon Sep 17 00:00:00 2001 From: Lilo Huang Date: Wed, 25 Jan 2023 12:49:08 +0800 Subject: [PATCH] Merge pull request #23172 from lilohuang:master Adding HEVC/H265 FourCC support to MSMF video writer * Adding HEVC/H265 fourcc to MSMF video writer Adding HEVC/H265 fourcc to MSMF video writer. I have verified it with my own video input stream, and it works well on my workstation. * Update video io testing * Adding macro fence to get rid of compiler error H265/HEVC encoder is only available in Windows or later. https://learn.microsoft.com/en-us/windows/win32/medfound/h-265---hevc-video-encoder * Update test_video_io.cpp --- modules/videoio/src/cap_msmf.cpp | 6 ++++++ modules/videoio/test/test_video_io.cpp | 2 ++ 2 files changed, 8 insertions(+) diff --git a/modules/videoio/src/cap_msmf.cpp b/modules/videoio/src/cap_msmf.cpp index 505814e96c..78eefc34a3 100644 --- a/modules/videoio/src/cap_msmf.cpp +++ b/modules/videoio/src/cap_msmf.cpp @@ -2469,6 +2469,12 @@ const GUID CvVideoWriter_MSMF::FourCC2GUID(int fourcc) #endif case CV_FOURCC_MACRO('H', '2', '6', '4'): return MFVideoFormat_H264; break; +#if defined(NTDDI_WIN10) + case CV_FOURCC_MACRO('H', '2', '6', '5'): + return MFVideoFormat_H265; break; + case CV_FOURCC_MACRO('H', 'E', 'V', 'C'): + return MFVideoFormat_HEVC; break; +#endif case CV_FOURCC_MACRO('M', '4', 'S', '2'): return MFVideoFormat_M4S2; break; case CV_FOURCC_MACRO('M', 'J', 'P', 'G'): diff --git a/modules/videoio/test/test_video_io.cpp b/modules/videoio/test/test_video_io.cpp index 595e1557ef..7d7944f5eb 100644 --- a/modules/videoio/test/test_video_io.cpp +++ b/modules/videoio/test/test_video_io.cpp @@ -388,6 +388,7 @@ static Ext_Fourcc_PSNR synthetic_params[] = { {"wmv", "WMV3", 30.f, CAP_MSMF}, {"wmv", "WVC1", 30.f, CAP_MSMF}, {"mov", "H264", 30.f, CAP_MSMF}, + // {"mov", "HEVC", 30.f, CAP_MSMF}, // excluded due to CI issue: https://github.com/opencv/opencv/pull/23172 #endif #ifdef HAVE_AVFOUNDATION @@ -991,6 +992,7 @@ static Ext_Fourcc_PSNR hw_codecs[] = { #ifdef _WIN32 {"mp4", "MPEG", 29.f, CAP_MSMF}, {"mp4", "H264", 29.f, CAP_MSMF}, + {"mp4", "HEVC", 29.f, CAP_MSMF}, #endif };