code: def extract_frames(
      main_data,
      resolution,
      format,
      q,
      quiet,
      transcoded,
      codec,
      crf,
      keyint,
  ):
      if transcoded:
          desc = [resolution, "scenes"]
          desc += [codec] if codec else []
          desc += ["crf" + crf] if crf else []
          desc += ["keyint" + keyint] if keyint else []
          in_path = os.path.join(main_data, *desc)
      else:
          if codec:
              raise ValueError(
                  "--codec specified, but not --transcoded"
              )
          if crf:
              raise ValueError("--crf specified, but not --transcoded")
          if keyint:
              raise ValueError(
                  "--keyint specified, but not --transcoded"
              )
          in_path = os.path.join(main_data, "orig", "scenes")
  
      desc = [resolution, "frames"]
      desc += [codec] if codec else []
      desc += ["crf" + crf] if crf else []
      desc += ["keyint" + keyint] if keyint else []
      if not format:
          format = default_format
      else:
          desc += [format]
  
      if not q:
          if format == "jpg":
              q = default_qscale_jpg
      else:
          desc += ["q" + q]
  
      out_path = os.path.join(main_data, *desc)
  
      res_args = []
      if resolution == "4K":
          pass
      else:
          if resolution == "1080p":
              res_str = "1920:1080"
          elif resolution == "720p":
              res_str = "1280:720"
          elif resolution == "540p":
              res_str = "960:540"
          else:
              raise ValueError("Unknown resolution")
          res_args += [
              "-vf",
              "scale=%s" % res_str,
              "-sws_flags",
              "bilinear",
          ]
  
      codec_args = []
      if format == "png":
          if q:
              codec_args += ["-compression_level", q]
      elif format == "jpg":
          codec_args += ["-q:v", q]
      else:
          raise ValueError("Unknown format")
  
      if quiet:
          cmdout = subprocess.DEVNULL
      else:
          cmdout = None
  
      for subset_name, subset_dir in [
          ("training", "train"),
          ("validation", "val"),
      ]:
          if not os.path.exists(os.path.join(in_path, subset_dir)):
              raise ValueError(
                  "No "
                  + subset_name
                  + " data found in "
                  + in_path
                  + ", "
                  + "did you run split_scenes.py?"
              )
  
          for in_file in os.listdir(os.path.join(in_path, subset_dir)):
              if in_file.endswith(".mp4"):
                  scene = in_file.split("_")[1].split(".")[0]
                  cur_out_path = os.path.join(
                      out_path, subset_dir, scene
                  )
                  if not os.path.isdir(cur_out_path):
                      os.makedirs(cur_out_path)
                  cur_in_path = os.path.join(
                      in_path, subset_dir, in_file
                  )
                  cmd = ["ffmpeg", "-n", "-i", cur_in_path]
                  cmd += res_args
                  cmd += codec_args
                  cmd += [os.path.join(cur_out_path, "%05d." + format)]
                  print("Running:", " ".join(cmd))
                  subprocess.run(cmd, stdout=cmdout, stderr=cmdout)
  
label_desc: Use image node_id 1 for calling a global function with example usage: extract_frames(main_data, resolution, format, q, quiet, transcoded, codec, crf, keyint) without return types