code: def crop_video(
      input_path,
      output_path,
      start_time,
      end_time,
      overwrite=False,
      min_video_length_ms=1000,
      crop_fn=crop_fn_ffmpeg,
      add_output_ts=False,
      make_dirs=False,
      *args,
      **kwargs,
  ):
      if add_output_ts:
          output_base, ext = os.path.splitext(output_path)
          output_path = "{name}_{t1}-{t2}{ext}".format(
              name=output_base, t1=start_time, t2=end_time, ext=ext
          )
  
      if not os.path.exists(input_path):
          raise ValueError(
              "input video path: {} does not exist".format(input_path)
          )
  
      if end_time - start_time < min_video_length_ms:
          raise ValueError(
              "End time - start time must be >= {min_len}, \
                            error for video: {path}".format(
                  min_len=min_video_length_ms, path=input_path
              )
          )
  
      parent_dir = os.path.dirname(output_path)
      if not os.path.exists(parent_dir):
          if make_dirs:
              os.makedirs(parent_dir, exist_ok=True)
          else:
              raise ValueError(
                  "Parent output directory for {} \
                                does not exist for input video path: {}".format(
                      output_path, input_path
                  )
              )
  
      if os.path.exists(output_path) and (not overwrite):
          return False, output_path
  
      with tempfile.TemporaryDirectory() as tmp_crop_dir_path:
          tmp_crop_path = os.path.join(
              tmp_crop_dir_path, os.path.basename(output_path)
          )
          crop_fn(
              input_path,
              tmp_crop_path,
              start_time,
              end_time,
              *args,
              **kwargs,
          )
  
          ret_code = call(["mv", tmp_crop_path, output_path])
          if ret_code:
              raise Exception(
                  "Failed to move to {} from tmp location".format(
                      output_path
                  )
              )
  
      return True, output_path
  
imports: import glob
  import numpy
  import os
  import re
  import tempfile
  from addict import Dict
  from collections import defaultdict
  from pathlib import Path
  from subprocess import call
  import cv2
  from ..dataset import GluonCVMotionDataset, DataSample, FieldNames, get_resized_video_location
  from ..io.video_io import VideoFrameReader, VideoSortedFolderReader, cmd_with_addn_args, FFMPEG_FOURCC
label_desc: Use image node_id 9 for calling a global function with example usage: crop_video(input_path, output_path, start_time, end_time, overwrite, min_video_length_ms, crop_fn, add_output_ts, make_dirs) and returns: True,  output_path, False,  output_path