code: def uniform_frame_sampling(
      video_path,
      num_frames,
      target_height,
      target_width,
      start_time=None,
      end_time=None,
  ):
      cap = cv2.VideoCapture(video_path)
      total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
      frame_rate = cap.get(cv2.CAP_PROP_FPS)
  
      if start_time is None:
          start_time = 0
      if end_time is None:
          end_time = total_frames / frame_rate
  
      start_frame = int(start_time * frame_rate)
      end_frame = int(end_time * frame_rate)
      frame_indices = list(
          range(
              start_frame,
              end_frame + 1,
              (end_frame - start_frame + 1) // num_frames,
          )
      )
  
      frames = []
      for frame_index in frame_indices:
          cap.set(cv2.CAP_PROP_POS_FRAMES, frame_index)
          ret, frame = cap.read()
          if not ret:
              break
          frame = cv2.resize(frame, (target_width, target_height))
          frames.append(frame)
  
      cap.release()
      return frames
  
imports: import gzip
  import logging
  import os
  import random
  import tarfile
  import zipfile
  import cv2
  import decord
  import webdataset
  import numpy
  import torch
  from torch.utils.data.dataset import IterableDataset, ChainDataset
  from decord import VideoReader
  from lavis.common.registry import registry
  from lavis.datasets.datasets.base_dataset import ConcatDataset
  from tqdm import tqdm
label_desc: Use image node_id 9 for calling a global function with example usage: uniform_frame_sampling(video_path, num_frames, target_height, target_width, start_time, end_time) and returns: frames