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 #3247 from cudawarped:videoreader_add_rtsp_feature
Add RTSP features to cudacodec::VideoReader
* Add live video source enhancements, e.g. rtsp from ip camera's
Add error logs.
* Fix type.
* Change badly named flag.
* Alter live source flag everywhere to indicate what it does not what it is for, which should be left up to the documentation.
* Prevent frame que object from being reinitialized which could be unsafe if another thread and/or object is using it.
Copy file name to clipboardExpand all lines: modules/cudacodec/include/opencv2/cudacodec.hpp
+27-14Lines changed: 27 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -321,6 +321,8 @@ enum class VideoReaderProps {
321
321
PROP_RAW_MODE = 4, //!< Status of raw mode.
322
322
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.
323
323
PROP_COLOR_FORMAT = 6, //!< Set the ColorFormat of the decoded frame. This can be changed before every call to nextFrame() and retrieve().
324
+
PROP_UDP_SOURCE = 7, //!< Status of VideoReaderInitParams::udpSource initialization.
325
+
PROP_ALLOW_FRAME_DROP = 8, //!< Status of VideoReaderInitParams::allowFrameDrop initialization.
324
326
#ifndef CV_DOXYGEN
325
327
PROP_NOT_SUPPORTED
326
328
#endif
@@ -468,32 +470,43 @@ class CV_EXPORTS_W RawVideoSource
@param udpSource Remove validation which can cause VideoReader() to throw exceptions when reading from a UDP source.
475
+
@param allowFrameDrop Allow frames to be dropped when ingesting from a live capture source to prevent delay and eventual disconnection
476
+
when calls to nextFrame()/grab() cannot keep up with the source's fps. Only use if delay and disconnection are a problem, i.e. not when decoding from
477
+
video files where setting this flag will cause frames to be unnecessarily discarded.
478
+
@param minNumDecodeSurfaces Minimum number of internal decode surfaces used by the hardware decoder. NVDEC will automatically determine the minimum number of
479
+
surfaces it requires for correct functionality and optimal video memory usage but not necessarily for best performance, which depends on the design of the
480
+
overall application. The optimal number of decode surfaces (in terms of performance and memory utilization) should be decided by experimentation for each application,
481
+
but it cannot go below the number determined by NVDEC.
482
+
@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).
@param params Pass through parameters for VideoCapure. VideoCapture with the FFMpeg back end (CAP_FFMPEG) is used to parse the video input.
475
-
The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`.
495
+
@param sourceParams Pass through parameters for VideoCapure. VideoCapture with the FFMpeg back end (CAP_FFMPEG) is used to parse the video input.
496
+
The `sourceParams` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`.
476
497
See cv::VideoCaptureProperties
477
498
e.g. when streaming from an RTSP source CAP_PROP_OPEN_TIMEOUT_MSEC may need to be set.
478
-
@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).
479
-
@param minNumDecodeSurfaces Minimum number of internal decode surfaces used by the hardware decoder. NVDEC will automatically determine the minimum number of
480
-
surfaces it requires for correct functionality and optimal video memory usage but not necessarily for best performance, which depends on the design of the
481
-
overall application. The optimal number of decode surfaces (in terms of performance and memory utilization) should be decided by experimentation for each application,
482
-
but it cannot go below the number determined by NVDEC.
499
+
@param params Initializaton parameters. See cv::cudacodec::VideoReaderInitParams.
483
500
484
501
FFMPEG is used to read videos. User can implement own demultiplexing with cudacodec::RawVideoSource
@param source RAW video source implemented by user.
490
-
@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).
491
-
@param minNumDecodeSurfaces Minimum number of internal decode surfaces used by the hardware decoder. NVDEC will automatically determine the minimum number of
492
-
surfaces it requires for correct functionality and optimal video memory usage but not necessarily for best performance, which depends on the design of the
493
-
overall application. The optimal number of decode surfaces (in terms of performance and memory utilization) should be decided by experimentation for each application,
494
-
but it cannot go below the number determined by NVDEC.
507
+
@param params Initializaton parameters. See cv::cudacodec::VideoReaderInitParams.
@@ -78,16 +79,17 @@ bool cv::cudacodec::detail::VideoParser::parseVideoData(const unsigned char* dat
78
79
79
80
if (cuvidParseVideoData(parser_, &packet) != CUDA_SUCCESS)
80
81
{
82
+
CV_LOG_ERROR(NULL, "Call to cuvidParseVideoData failed!");
81
83
hasError_ = true;
82
84
frameQueue_->endDecode();
83
85
returnfalse;
84
86
}
85
87
86
-
constexprint maxUnparsedPackets = 20;
87
-
88
88
++unparsedPackets_;
89
-
if (unparsedPackets_ > maxUnparsedPackets)
89
+
if (maxUnparsedPackets_ && unparsedPackets_ > maxUnparsedPackets_)
90
90
{
91
+
CV_LOG_ERROR(NULL, "Maxium number of packets (" << maxUnparsedPackets_ << ") parsed without decoding a frame or reconfiguring the decoder, if reading from \
92
+
a live source consider initializing with VideoReaderInitParams::udpSource == true.");
91
93
hasError_ = true;
92
94
frameQueue_->endDecode();
93
95
returnfalse;
@@ -122,7 +124,8 @@ int CUDAAPI cv::cudacodec::detail::VideoParser::HandleVideoSequence(void* userDa
0 commit comments