def _peek_first_frame(
        self, frame_iter: Iterator[FrameDescriptor]
    ) -> tuple[Optional[FrameDescriptor], Iterator[FrameDescriptor]]:
        "Gets the first frame and returns the same full iterator"

        if not hasattr(frame_iter, '__next__'):
            frame_iter = iter(frame_iter)

        first_frame = next(frame_iter, None)
        return first_frame, itertools.chain((first_frame, ), frame_iter)
Gets the first frame and returns the same full iterator
cvat/apps/engine/media_extractors.py