Ask Your Question

Revision history [back]

Get frame number or manifest time stamp of live stream HLS/m3u8

I am using VideoCapture to read frames from a HLS live stream and processing the frames asynchronously so i need a method to keep the frames and the returned data in sync.

Is it possible to get the timestamp or frame number or EXT-X-MEDIA-SEQUENCE or .ts filename or some kind of identifying number relative to the live stream's frame?

cap.get(cv2.CAP_PROP_POS_FRAMES) and cap.get(cv2.CAP_PROP_POS_MSEC) get the frame number and timestamp relative to when videocapture starts reading from the stream. (eg: if videocapture started when the stream was on frame 5000, when live stream is on frame 5010, frame number would return only 10). This becomes a bigger problem if my videocapture function breaks then i lose all sense of order with the frames.

is there anything in opencv that would allow me to get some form of identification for a frame relative to the stream or would I, for example, have to use ffmpeg which could have a method to get that data and get the frames using that instead then process with opencv?

Id prefer to use python but c++ could be an option for the frame reading if needed