Merge pull request #20591 from fortemSteve:ffmpeg_get_stream_open_time

Add CAP_PROP_STREAM_OPEN_TIME

* Added CAP_PROP_STREAM_OPEN_TIME to videoio module - can be used to query the time at which the stream was opened, in seconds since Jan 1 1970 (midnight, UTC). Useful for RTSP and other live video where absolute timestamps are needed. Only applicable to ffmpeg backends

* use nanoseconds instead of seconds to mark the stream open time, and change the cap prop name to CAP_PROP_STREAM_OPEN_TIME_NSEC

* use microseconds for CAP_PROP_STREAM_OPEN_TIME (nanoseconds rolls over too soon, and milliseconds/seconds requires a division)

* fix whitespace issue
pull/20684/head
fortemSteve 3 years ago committed by GitHub
parent c703f1eed6
commit c7e0888982
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      modules/videoio/include/opencv2/videoio.hpp
  2. 3
      modules/videoio/src/cap_ffmpeg_impl.hpp

@ -188,6 +188,7 @@ enum VideoCaptureProperties {
CAP_PROP_HW_ACCELERATION_USE_OPENCL=52, //!< (**open-only**) If non-zero, create new OpenCL context and bind it to current thread. The OpenCL context created with Video Acceleration context attached it (if not attached yet) for optimized GPU data copy between HW accelerated decoder and cv::UMat.
CAP_PROP_OPEN_TIMEOUT_MSEC=53, //!< (**open-only**) timeout in milliseconds for opening a video capture (applicable for FFmpeg back-end only)
CAP_PROP_READ_TIMEOUT_MSEC=54, //!< (**open-only**) timeout in milliseconds for reading from a video capture (applicable for FFmpeg back-end only)
CAP_PROP_STREAM_OPEN_TIME_USEC =55, //<! (read-only) time in microseconds since Jan 1 1970 when stream was opened. Applicable for FFmpeg backend only. Useful for RTSP and other live streams
#ifndef CV_DOXYGEN
CV__CAP_PROP_LATEST
#endif

@ -1591,6 +1591,9 @@ double CvCapture_FFMPEG::getProperty( int property_id ) const
case CAP_PROP_HW_ACCELERATION_USE_OPENCL:
return static_cast<double>(use_opencl);
#endif // USE_AV_HW_CODECS
case CAP_PROP_STREAM_OPEN_TIME_USEC:
//ic->start_time_realtime is in microseconds
return ((double)ic->start_time_realtime);
default:
break;
}

Loading…
Cancel
Save