I successfully managed to create a gstreamer pipeline to read frames into
Python using OpenCV cv2.VideoCapture.
I understand that gstreamer has a buffer through which it is possible to
read the timestamp at which the current frame was taken, but it is not clear
to me if it is possible to access this information through python and how.
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.
I don't need to have the timestamp embedded in the frame as of now. The
reason I want it is to be able to synchronize and record multiple cameras,
some of which are accessed through gstreamer and some directly through
Python (and that can't be accessed by gstreamer). What I do is basically
load the frames from gstreamer in a loop as I showed and then send them to
another gstreamer pipeline to encode them and write them to a video file.
So far OpenCV VideoCapture and VideoWriter worked for me, but if there is a
better way to manage gstreamer capture in a loop I'm open to suggestions! I
am very new to gstreamer, I'm trying to learn my way through it.