Open VideoCapture from data stream#25584
Conversation
2bd1a39 to
023eeb5
Compare
4dace6c to
b71844d
Compare
opencv-alalek
left a comment
There was a problem hiding this comment.
Plugin support is necessary - it is mandatory for FFmpeg support on Windows.
ec90def to
eeae54d
Compare
|
Discussed on OpenCV weekly sync about potential improvements:
|
|
We have something similar in cudacodec module:
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 |
|
Hello, what is left to complete this work? Would anyone be able to complete this work by any chance? |
|
@gdippolito, I can complete this one once I can figure out which API is better. Last time we discussed in the team, more generic is to introduce kind of streaming API which returns chunks of video buffer. |
eeae54d to
175f070
Compare
214cd8a to
62cd53a
Compare
|
Hey @dkurt thanks for your work on this PR. Do you think this is ready for some testing? |
|
@gdippolito, thanks! Yes, it's ready and any feedback is welcome. |
Totally fine to keep stream notation everywhere. There is just a conflict in public API with filename (getStreamBackends) |
modules/videoio/src/cap_ffmpeg.cpp
Outdated
| try | ||
| { | ||
| cv::VideoCaptureParameters parameters(params, n_params); | ||
| cap = new CvCapture_FFMPEG_proxy(makePtr<ReadStreamPluginProvider>(opaque, read, seek), parameters); |
There was a problem hiding this comment.
makePtr<ReadStreamPluginProvider>(opaque, read, seek)
Released right after this call because it is not saved anywhere.
There was a problem hiding this comment.
As a workaround, readStream = stream for now
ffb04fd to
ad2b7b3
Compare
ad2b7b3 to
64a7d96
Compare
|
|
||
| /** @brief Read data stream interface | ||
| */ | ||
| class CV_EXPORTS_W IReadStream |
There was a problem hiding this comment.
@opencv-alalek, @asmorkalov , need your opinion on naming as we ready to move it to the public API. There are VideoCapture, IStreamSource , VideoReader, VideoWriter. So does it make sense to keep the order and name it IStreamReader? Moreover, it matches PyTorch's naming: https://pytorch.org/audio/main/generated/torchaudio.io.StreamReader.html#streamreader
IReadStream -> IStreamReader ReadStreamPluginProvider -> PluginStreamReader PythonReadStream -> PythonStreamReader BufferBackend -> StreamBufferedBackend
|
BTW, there is leftover with Python typing generator (map to |
2a02297 to
cfed93c
Compare
|
There is problem with iOS/Swift bindings: Error message is not very clear to me |
|
Looks like fix works: https://github.com/opencv/opencv/actions/runs/12491953263/job/34858615536?pr=25584 @dkurt Feel free to push your changes. |
|
@opencv-alalek no pending changes left |
| /** @brief Sets the stream position | ||
| * | ||
| * @param offset Seek offset | ||
| * @param origin SEEK_SET / SEEK_END / SEEK_CUR |
There was a problem hiding this comment.
Wouldn't it be better to completely avoid C/C++ constants in public interface and introduce our own?
There was a problem hiding this comment.
FFmpeg (basically) and Python use them too (with same values).
IMHO, it is not necessary to introduce extra conversions to/from own values.
There was a problem hiding this comment.
Agree, we can add such enum but potential user will still cast to integer or introduce long if/else/switch
There was a problem hiding this comment.
My concern was that user would be required to include <stdio.h>/<cstdio> in order to use this seemingly unrelated class. Though perhaps it's fine.
Open VideoCapture from data stream opencv#25584 ### Pull Request Readiness Checklist Add VideoCapture option to read a raw binary video data from `std::streambuf`. There are multiple motivations: 1. Avoid disk file creation in case of video already in memory (received by network or from database). 2. Streaming mode. Frames decoding starts during sequential file transfer by chunks. Suppoted backends: * FFmpeg * MSMF (no streaming mode) Supporter interfaces: * C++ (std::streambuf) * Python (io.BufferedIOBase) resolves opencv#24400 - [x] test h264 - [x] test IP camera like approach with no metadata but key frame only? - [x] C API plugin See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
Open VideoCapture from data stream opencv#25584 ### Pull Request Readiness Checklist Add VideoCapture option to read a raw binary video data from `std::streambuf`. There are multiple motivations: 1. Avoid disk file creation in case of video already in memory (received by network or from database). 2. Streaming mode. Frames decoding starts during sequential file transfer by chunks. Suppoted backends: * FFmpeg * MSMF (no streaming mode) Supporter interfaces: * C++ (std::streambuf) * Python (io.BufferedIOBase) resolves opencv#24400 - [x] test h264 - [x] test IP camera like approach with no metadata but key frame only? - [x] C API plugin See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
Pull Request Readiness Checklist
Add VideoCapture option to read a raw binary video data from
std::streambuf.There are multiple motivations:
Suppoted backends:
Supporter interfaces:
resolves #24400
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.