opencv / opencv

Open Source Computer Vision Library
https://opencv.org
Apache License 2.0
76.54k stars 55.64k forks source link

Open VideoCapture from memory buffer #25584

Open dkurt opened 1 month ago

dkurt commented 1 month ago

Pull Request Readiness Checklist

Suppoted backends:

resolves https://github.com/opencv/opencv/issues/24400

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

dkurt commented 1 week ago

Discussed on OpenCV weekly sync about potential improvements:

  1. On current PR state, do not use std::vector but allow user pass just pointer/buffer_size.
  2. Consider alternative API with a kind of streaming by chunks. Might be more efficient with GPU decoders.
mshabunin commented 1 week ago

We have something similar in cudacodec module:

RawVideoSource object is an iterator over encoded data stream (https://github.com/opencv/opencv_contrib/blob/b236c71c2f8d983403c35a0cea8bec0432a4b0fe/modules/cudacodec/include/opencv2/cudacodec.hpp#L508-L555) and can be used to construct VideoReader (https://github.com/opencv/opencv_contrib/blob/b236c71c2f8d983403c35a0cea8bec0432a4b0fe/modules/cudacodec/include/opencv2/cudacodec.hpp#L604).

Following example in the test decodes key frames (if I understand corretly): https://github.com/opencv/opencv_contrib/blob/b236c71c2f8d983403c35a0cea8bec0432a4b0fe/modules/cudacodec/test/test_video.cpp#L178-L209