Accessing gstreamer timestamp from python
Michael Gruner
michael.gruner at ridgerun.com
Mon Apr 5 16:08:00 UTC 2021
Hello Letty
The limitation here is OpenCV rather than Python. The way the GStreamer VideoCapture works is that it will make a copy of the GstBuffer’s data into a newly allocated cv::Mat. As such, once you do a cap.read(), you don’t have access to the GstBuffer nor its timestamp anymore.
Having said that, if you’re looking for a workaround, here’s the precise line that makes the copy:
https://github.com/opencv/opencv/blob/125b9f60574d40cbd59f5927646c385bba96f526/modules/videoio/src/cap_gstreamer.cpp#L1937
Maybe you can read the timestamp from there and embed this info in the first bytes of the image. Not the prettiest solution though ¯\_(ツ)_/¯.
You’ll need to build OpenCV from source, here are some instructions:
https://developer.ridgerun.com/wiki/index.php?title=Compiling_OpenCV_from_Source
Make sure to enable the GStreamer option.
Michael
www.ridgerun.com
> On 2 Apr 2021, at 04:26, Letty <letizia.mariotti at gmail.com> wrote:
>
> Apologie but my code didn't show up. Here it is
>
> This is my gstreamer pipeline:
>
> gst_in = ('nvarguscamerasrc sensor-id=0 ! '
> 'video/x-raw(memory:NVMM), height=1080, width=1920,
> framerate=(fraction)30/1, format=NV12 ! '
> 'nvvidconv ! video/x-raw, height=1080, width=1920, format=BGRx ! '
> 'videoconvert ! video/x-raw, format=BGR ! '
> 'appsink')
>
> which then I call through VideoCapture
>
> cap = cv2.VideoCapture(gst_in, cv2.CAP_GSTREAMER)
>
> while True:
> ret, frame = cap.read()
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
More information about the gstreamer-devel
mailing list