Automatically write RTSP streams to file during VideoCapture Decode with FFmpeg#20444
Automatically write RTSP streams to file during VideoCapture Decode with FFmpeg#20444cudawarped wants to merge 9 commits intoopencv:4.xfrom
Conversation
…ng frames with ffmpeg backend. Plugins not compiled or tested.
|
OpenCV_contrib contains cudacodec module that utilizes |
|
I understand that the raw stream can be retrieved, however it cannot be decoded on the CPU with FFMPEG at the same time as being written to disk without re-encoding. This would be useful when reading from an IP camera, processing the recieved video and archiving the footage. Currently to do this would require the overhead of wastefully re-encoding the decoded frames. This would also not result in an exact copy of the streamed data due to re-encoding. This functionality could be added directly to cudacodec, however I thought it might be easier to add it directly to VideoCapture so that it can be seamlessly used by cudacodec, any class like cudacodec with reads the raw stream for decoding and VideoCapture. Additionaly it removes the need for querying when a new key frame occurs and/or manually parsing the raw stream for the frame type. |
…opencv into add_rtsp_video_write # Conflicts: # modules/videoio/src/cap_ffmpeg_impl.hpp
|
@asmorkalov and then any subsequent calls to Additionaly if a From your comments I assume it is not desirable to add these extra api calls to If not I can just leave this feature out from Would this alternative be acceptable? |
It is really common these days to live stream directly from IP camera's and perform image processing on the decoded frames. Because the data is live it is also desirable to save the original data somewhere for archival and/or later processing. Currently the only way to do this is to re-encode the decoded frames, which has a significant overhead and will not be produce an exact duplicate of the source, due to encoding differences.
The pull request adds the functionality to write the raw bitstream to a given file during the calls to read()/grab(). It seemed appropriate to place this functionality there because it can also be utilized when reading raw data only, currently used by cudacodec.
Additionally I added the capacity for raw reads to append the side info which is commonly provided when streaming from and RTSP source to the beginning of the stream. This will mostly be a duplicate but some IP cameras, from memory axis is one, don't send the SPS and PPS in band.
In loop restart of recording cannot be tested because there are no media test file with more than one key frame. If this pull request is suitable for inclusion it may be worth including an extra media file and test.
Pull Request Readiness Checklist
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.