code: def _ffmpeg_decode_diskless(
      path,
      extra_ffmpeg_input_args,
      extra_ffmpeg_output_args,
      num_target_frames,
      timeout=None,
  ):
      """Reads a video from a file, without using the disk.
  
      Args:
        path: File to read the video from.
        extra_ffmpeg_input_args: Additional input arguments / flags for ffmpeg.
        extra_ffmpeg_output_args: Additional output arguments / flags for ffmpeg.
        num_target_frames: If not None, how many frames to return at most.
        timeout: If not None, maximum amount of seconds to use when running ffmpeg.
  
      Returns:
        Video frames encoded with encoding_format.
      """
      data = epath.Path(path).read_bytes()
      if not data:
          raise ValueError("Empty file.")
  
      # FFMPEG args: input from pipe.
      args = ["-i", "pipe:0"]
      args.extend(extra_ffmpeg_input_args)
      # output to pipe.
      args += ["-f", "image2pipe"]
      args.extend(extra_ffmpeg_output_args)
  
      # Extract the specified number of frames (or all frames if num_frames == 0).
      assert num_target_frames is None or (
          isinstance(num_target_frames, int) and num_target_frames >= 0
      )
      if num_target_frames:
          args += ["-frames:v", f"{num_target_frames}"]
  
      # Output to pipe.
      args += ["-"]
      output = tfds.core.utils.image_utils.ffmpeg_run(
          args=args, stdin=data, timeout=timeout
      )
  
      jpegs = _split_mjpeg_stream(output)
      if num_target_frames:
          jpegs = jpegs[:num_target_frames]
      return jpegs
  
file_path: datasets/tensorflow_datasets/datasets/webvid/webvid_dataset_builder.py
imports: import io
  import os
  import pathlib
  import subprocess
  from typing import List
  from absl import logging
  from etils import epath
  import tensorflow_datasets.public_api
label_desc: Use image node_id 2 for calling a global function with example usage: _ffmpeg_decode_diskless(path, extra_ffmpeg_input_args, extra_ffmpeg_output_args, num_target_frames, timeout) and returns: jpegs