AINVR issues with recorded vst videos

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson Orin NX16)
• DeepStream Version 7.0
• JetPack Version 6 36.3

In VST i’m trying to use the recorded videos, the problem is, the fps changes constantly and the video is recorded that way, i need the recorded videos for the follwing process:

  • Fetch the metadata saved by deepstream and emdx for a certain timerange
  • Match the timestamp of each object in the metadata with the video that corresponds to it (generally for a narrow timerange it’s only one video)
  • Retrieve the video and open it with CV2, fetch the frame that is in the timestamp of the metadata and draw the bboxes on it.

My problem is, when the FPs is changing, i can’t get the right frame to draw the bboxes on, thus the bboxes would be off. This is the way i get the frame:

def extract_frame_opencv(video_file, timestamp, output_image):
    """
    Extract a frame from the video at a specific timestamp using OpenCV.

    Parameters:
    - video_file (str): The path to the video file.
    - timestamp (timedelta): The timestamp at which to extract the frame.
    - output_image (str): The output path where the frame will be saved.

    Returns:
    - bool: True if the frame was successfully extracted and saved, False otherwise.
    """
    # Open the video file
    cap = cv2.VideoCapture(video_file)
    if not cap.isOpened():
        print(f"Error: Could not open video file {video_file}")
        return False

    # Get the frames per second (fps) of the video to calculate the frame number
    fps = cap.get(cv2.CAP_PROP_FPS)
    frame_number = int(fps * timestamp.total_seconds())  # Calculate frame index at the timestamp
    print(f"Timestamp: {timestamp}, FPS: {fps}, Frame number: {frame_number}")

    cap.set(cv2.CAP_PROP_POS_FRAMES, frame_number)

    ret, frame = cap.read()
    if ret:
        cv2.imwrite(output_image, frame)
        print(f"Frame at {timestamp} seconds saved as {output_image}")
        cap.release()
        return True
    else:
        print(f"Error: Could not read frame at {timestamp} seconds.")
        cap.release()
        return False

Is there a way to set a fixed fps? or any parameter in VST that can help in my case

Is it possible to use cv2.CAP_PROP_POS_MSEC to read video frame based on timestamp?