Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass cv::VideoCaptureProperties to VideoReader FFmpeg source #3139

Merged
merged 12 commits into from
Dec 28, 2021

Conversation

cudawarped
Copy link
Contributor

@cudawarped cudawarped commented Dec 24, 2021

Allow initialization properties CAP_PROP_OPEN_TIMEOUT_MSEC, CAP_PROP_READ_TIMEOUT_MSEC etc. to be passed to the FFmpeg backend which is used by cv::cudacodec::VideoReader.
See #3138

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 other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to 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
force_builders=Custom
buildworker:Custom=linux-4,linux-6
build_image:Custom=ubuntu-cuda:18.04

James Bowley and others added 9 commits June 11, 2019 09:57
…luding checks to ensure codec used in input video file is supported on the current device.
# Conflicts:
#	modules/cudacodec/include/opencv2/cudacodec.hpp
#	modules/cudacodec/src/video_decoder.cpp
…zation.

Include test for VideoReader but not for VideoCapture, assume pass through successful.
Use propertyId instead of c++ keyword property.
Remove unecessary error checks (parsers error is dependant on source) and output more informative exception.
@cudawarped cudawarped changed the title Pass videocapture params to Videoeader Pass cv::VideoCaptureProperties to VideoReader FFmpeg source Dec 24, 2021
…sed and initialization fails and add test for this.
Comment on lines 390 to 391
@return Value for the specified property. Value 0 is returned when querying a property that is
not supported.
Copy link
Member

Choose a reason for hiding this comment

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

Value 0 is returned when querying a property that is not supported.

BTW, Zero is not a good "non-supported" value due to conflict with regular values of supported properties. It would be changed in the future somehow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have changed both get methods to return the status to avoid magic numbers.

@@ -176,6 +178,16 @@ void cv::cudacodec::detail::FFmpegVideoSource::updateFormat(const FormatInfo& vi
format_.valid = true;
}

double cv::cudacodec::detail::FFmpegVideoSource::get(const int propId) const
{
if (videoCaptureParams.size() % 2 != 0) return 0;
Copy link
Member

Choose a reason for hiding this comment

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

CV_Assert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, it should have failed earlier if true.

*/
CV_WRAP virtual int get(const VideoReaderProps propertyId, const int propertyVal = -1) const = 0;
CV_WRAP virtual bool get(const VideoReaderProps propertyId, double& propertyValOut, const int propertyVal = -1) const = 0;
Copy link
Member

Choose a reason for hiding this comment

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

CV_WRAP

It needs to add CV_OUT specifier:

CV_OUT double& propertyValOut

const int propertyVal = -1

Perhaps we don't need this anymore.

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.

LGTM 👍

@alalek alalek merged commit 758c1a9 into opencv:4.x Dec 28, 2021
@alalek alalek mentioned this pull request Dec 30, 2021
@alalek alalek mentioned this pull request Feb 22, 2022
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.

Pass additional options to cv::cuda::VideoReader
2 participants