You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge pull request #3098 from cudawarped:rtsp_video_write
Add writing encoded video streams to disk when streaming from RTSP sources using cudacodec
* Add missing codecs to cudacodec which uses Nvidia Video Codec SDK including checks to ensure codec used in input video file is supported on the current device.
* Update cudacoded to
1) automatically write the raw encoded video stream to a video file and,
2) use less GPU memory by more closely mirroring the Nvidia samples. Specifically querying the decoder for the number of decode surfaces (h265 commonly uses 4) instead of always using 20 and not using adaptive deinterlacing when the video sequence is progressive. Additional updates to mirror the Nvidia sample include initializing the decoder so that HandleVideoSequence() gets called every time before the decoder is initialized, ensuring all the parameters for the decoder are provided by nvcudec.
Added facility to decode AV1, not tested as VideoCapture doesn't return a valid fourcc for this.
Add facility to decode MPEG4 video - requires modification to VideoCapture see pull request.
* Prevent adding parameter sets twice and add zero padding to output files to that they play in vlc.
Notes: VideoCapture - returns mpeg as the codec for mpeg4 files, so files written as .m4v from mpeg4 sources cannot currently be decoded. This is also true for AV1 sources where cap.get(CAP_PROP_FOURCC) returns 0.
Added mpeg4 test file which can be decoded when VideoCapture adds the extra_data.
* Update to account for the extraData being passed from cap.retrieve instead of appended to the first packet.
* Update to be compatible with changes to VideoCapture
* Remove redundant test.
* Add check to ensure retrieve is successful.
* Remove writeToFile and allow VideoReader to return raw encoded data at the same time as decoded frames.
* Fix missing documentation.
PROP_DECODED_FRAME_IDX = 0, //!< Index for retrieving the decoded frame using retrieve().
315
+
PROP_EXTRA_DATA_INDEX = 1, //!< Index for retrieving the extra data associated with a video source using retrieve().
316
+
PROP_RAW_PACKAGES_BASE_INDEX = 2, //!< Base index for retrieving raw encoded data using retrieve().
317
+
PROP_NUMBER_OF_RAW_PACKAGES_SINCE_LAST_GRAB = 3, //!< Number of raw packages recieved since the last call to grab().
318
+
PROP_RAW_MODE = 4, //!< Status of raw mode.
319
+
PROP_LRF_HAS_KEY_FRAME = 5//!< FFmpeg source only - Indicates whether the Last Raw Frame (LRF), output from VideoReader::retrieve() when VideoReader is initialized in raw mode, contains encoded data for a key frame.
290
320
};
291
321
292
322
/** @brief Video reader interface.
@@ -310,6 +340,48 @@ class CV_EXPORTS_W VideoReader
310
340
/** @brief Returns information about video file format.
311
341
*/
312
342
virtual FormatInfo format() const = 0;
343
+
344
+
/** @brief Grabs the next frame from the video source.
345
+
346
+
@return `true` (non-zero) in the case of success.
347
+
348
+
The method/function grabs the next frame from video file or camera and returns true (non-zero) in
349
+
the case of success.
350
+
351
+
The primary use of the function is for reading both the encoded and decoded video data when rawMode is enabled. With rawMode enabled
352
+
retrieve() can be called following grab() to retrieve all the data associated with the current video source since the last call to grab() or the creation of the VideoReader.
@param [out] frame The returned data which depends on the provided idx. If there is no new data since the last call to grab() the image will be empty.
359
+
@param idx Determins the returned data inside image. The returned data can be the:
360
+
Decoded frame, idx = get(PROP_DECODED_FRAME_IDX).
361
+
Extra data if available, idx = get(PROP_EXTRA_DATA_INDEX).
362
+
Raw encoded data package. To retrieve package i, idx = get(PROP_RAW_PACKAGES_BASE_INDEX) + i with i < get(PROP_NUMBER_OF_RAW_PACKAGES_SINCE_LAST_GRAB)
363
+
@return `false` if no frames has been grabbed
364
+
365
+
The method returns data associated with the current video source since the last call to grab() or the creation of the VideoReader. If no data is present
366
+
the method returns false and the function returns an empty image.
@param rawMode Allow the raw encoded data which has been read up until the last call to grab() to be retrieved by calling retrieve(rawData,RAW_DATA_IDX).
343
426
344
427
FFMPEG is used to read videos. User can implement own demultiplexing with cudacodec::RawVideoSource
@param source RAW video source implemented by user.
433
+
@param rawMode Allow the raw encoded data which has been read up until the last call to grab() to be retrieved by calling retrieve(rawData,RAW_DATA_IDX).
0 commit comments