Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

lilohuang
Copy link
Contributor

@lilohuang lilohuang commented Jan 23, 2023

Adding HEVC/H265 FourCC support to MSMF video writer. I have verified it with my own video input stream, and it works well on my workstation.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

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.
@alalek
Copy link
Member

alalek commented Jan 23, 2023

into opencv:master

master is not a valid branch for contribution: https://github.com/opencv/opencv/wiki/Branches
Please use 4.x (it is default on GitHub) - use "Edit" button near PR title to change the target branch


Please update videoio tests to check added new functionality for MSMF.

@lilohuang lilohuang changed the base branch from master to 4.x January 23, 2023 14:32
@alalek
Copy link
Member

alalek commented Jan 24, 2023

There is a problem on CI with H265/HEVC tests:

cap_msmf.cpp:930 CvCapture_MSMF::initStream Failed to set mediaType (stream 0, (640x480 @ 25) MFVideoFormat_RGB32(codec not found)

Added this package:

Microsoft.HEVCVideoExtension_2.0.60091.0_x64__8wekyb3d8bbwe.appx


No changes on CI
But it works locally.
Perhaps problem is related to CI launcher - CI has no active GUI because it runs as service.

@lilohuang
Copy link
Contributor Author

lilohuang commented Jan 24, 2023

There is a problem on CI with H265/HEVC tests:

cap_msmf.cpp:930 CvCapture_MSMF::initStream Failed to set mediaType (stream 0, (640x480 @ 25) MFVideoFormat_RGB32(codec not found)

Added this package:

Microsoft.HEVCVideoExtension_2.0.60091.0_x64__8wekyb3d8bbwe.appx

No changes on CI But it works locally. Perhaps problem is related to CI launcher - CI has no active GUI because it runs as service.

Hi @alalek ,

Thanks for your feedback. I guess CI enviroment cannot fully support MSMF. BTW, you're referring to an error (i.e. MFVideoFormat_RGB32) which seems to be irrelevant to my recent HEVC/H264 FourCC code change.

I only saw 2 failed tests from here (https://pullrequest.opencv.org/buildbot/builders/precommit_custom_windows/builds/100080/steps/test_videoio/logs/tests%20summary),

Should I remove HEVC/H265 from the "videoio_synthetic" unit test, or any suggestion to move forward?

Thank you,
Lilo

Copy link
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! Thank you for the contribution 👍

@alalek alalek merged commit cb7fe59 into opencv:4.x Jan 25, 2023
@lilohuang
Copy link
Contributor Author

Well done! Thank you for the contribution 👍

Thank you :)

@TrueWodzu
Copy link

TrueWodzu commented Jan 26, 2023

@lilohuang I want to tray that (and report back), Is it enough to build latest OpenCV with WITH_FFMPEG and OPENCV_ENABLE_NONFREE or do I have to download custom ffmpeg libraries and somehow point to them during CMake configuration?

@lilohuang
Copy link
Contributor Author

lilohuang commented Jan 26, 2023

@lilohuang I want to tray that (and report back), Is it enough to build latest OpenCV with WITH_FFMPEG and OPENCV_ENABLE_NONFREE or do I have to download custom ffmpeg libraries and somehow point to them during CMake configuration?

@TrueWodzu This PR is nothing to do with FFMPEG, it's all about MSMF (Microsoft Media Foundation). You need to enable WITH_MSMF and compile OpenCV with Windows 10 SDK to take the benefit of Microsoft Media Foundation H265 encoder . Good luck!

@TrueWodzu
Copy link

@lilohuang Thank you so much for you answer, to this day I have thought that you I can have VideoWriter only with ffmpeg or gstreamer!

@alalek alalek mentioned this pull request Jan 28, 2023
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
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
@asmorkalov asmorkalov mentioned this pull request May 31, 2023
geversonsto pushed a commit to stodev-com-br/opencv that referenced this pull request Jun 3, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants