def fetch_video_chunk(self, start_time: float, duration: float, output_file: str) -> str:
        """
        Fetch a video chunk from the url, starting at start_time and lasting duration seconds. Return the path to the
        downloaded video chunk.
        Args:
            start_time: The start time of the video chunk
            duration: The duration of the video chunk
            output_file: The path to save the video chunk

        Returns:
            THe path to the downloaded video chunk

        Raises:
            MediaDownloadError: If there is an error downloading the video chunk
        """
        ffmpeg_command = [
            'ffmpeg',
            '-y',  # Enable overwrite
            '-v', 'error',  # Suppress warnings and other output
        ]

        if self.media_download_header:
            # -headers must appear before -i
            ffmpeg_command.extend(['-headers', self.media_download_header])

        if self.enable_video_gpu_acceleration:
            ffmpeg_command.extend([
                '-ss', str(start_time),  # Start time
                '-t', str(duration),  # Duration
                '-hwaccel', 'cuda',  # Use GPU acceleration
                '-hwaccel_output_format', 'cuda',  # Use GPU acceleration
                '-i', self.url,  # Input file
                '-c:a', 'copy', # Copy audio codec to speed up the conversion process by avoiding unnecessary re-encoding of the audio stream.
                '-c:v', 'h264_nvenc', # Use NVIDIA NVENC H.264 encoder
                '-b:v', '5M', # Set the video bitrate to 5M
                output_file
            ])
            timeout = duration * self.VIDEO_GPU_TIMOUT_OUT_MULTIPLIER
        else:
            ffmpeg_command.extend([
                '-ss', str(start_time),  # Start time
                '-t', str(duration),  # Duration
                '-i', self.url,  # Input file
                '-vcodec', 'libx264',
                '-acodec', 'aac',
                '-f', 'mp4',
                output_file
            ])
            timeout = duration * self.VIDEO_CPU_TIMOUT_OUT_MULTIPLIER

        base_error_message = f"Error downloading the video chunk with url={self.url}, start_time={start_time},"

        try:
            self._run_ffmpeg_command(ffmpeg_command, timeout, base_error_message)
        except (MediaDownloadError, InternalError):
            if os.path.exists(output_file): # Remove the file if it was created
                os.remove(output_file)
            raise
        return output_file

        Fetch a video chunk from the url, starting at start_time and lasting duration seconds. Return the path to the
        downloaded video chunk.
        Args:
            start_time: The start time of the video chunk
            duration: The duration of the video chunk
            output_file: The path to save the video chunk

        Returns:
            THe path to the downloaded video chunk

        Raises:
            MediaDownloadError: If there is an error downloading the video chunk
        
src/marqo/inference/media_download_and_preprocess/streaming_media_processor.py