code: def reencode_videos(
      sample_collection,
      force_reencode=True,
      media_field="filepath",
      output_field=None,
      output_dir=None,
      rel_dir=None,
      update_filepaths=True,
      delete_originals=False,
      skip_failures=False,
      verbose=False,
      **kwargs,
  ):
      """Re-encodes the videos in the sample collection as H.264 MP4s that can be
      visualized in the FiftyOne App.
  
      If no ``output_dir`` is specified and ``delete_originals`` is False, then
      if a transformation would result in overwriting an existing file with the
      same filename, the original file is renamed to ``<name>-original.<ext>``.
  
      By default, the re-encoding is performed via the following ``ffmpeg``
      command::
  
          ffmpeg \\
              -loglevel error -vsync 0 -i $INPUT_PATH \\
              -c:v libx264 -preset medium -crf 23 -pix_fmt yuv420p -vsync 0 -an \\
              $OUTPUT_PATH
  
      You can configure parameters of the re-encoding such as codec and
      compression by passing keyword arguments for
      ``eta.core.video.FFmpeg(**kwargs)`` to this function.
  
      .. note::
  
          This method will not update the ``metadata`` field of the collection
          after transforming. You can repopulate the ``metadata`` field if needed
          by calling::
  
              sample_collection.compute_metadata(overwrite=True)
  
      Args:
          sample_collection: a
              :class:`fiftyone.core.collections.SampleCollection`
          force_reencode (True): whether to re-encode videos that are already
              MP4s
          media_field ("filepath"): the input field containing the video paths to
              transform
          output_field (None): an optional field in which to store the paths to
              the transformed videos. By default, ``media_field`` is updated
              in-place
          output_dir (None): an optional output directory in which to write the
              transformed videos. If none is provided, the videos are updated
              in-place
          rel_dir (None): an optional relative directory to strip from each input
              filepath to generate a unique identifier that is joined with
              ``output_dir`` to generate an output path for each video. This
              argument allows for populating nested subdirectories in
              ``output_dir`` that match the shape of the input paths
          update_filepaths (True): whether to store the output paths on the
              sample collection
          delete_originals (False): whether to delete the original videos after
              re-encoding
          skip_failures (False): whether to gracefully continue without raising
              an error if a video cannot be re-encoded
          verbose (False): whether to log the ``ffmpeg`` commands that are
              executed
          **kwargs: keyword arguments for ``eta.core.video.FFmpeg(**kwargs)``
      """
      fov.validate_video_collection(sample_collection)
  
      _transform_videos(
          sample_collection,
          reencode=True,
          force_reencode=force_reencode,
          media_field=media_field,
          output_field=output_field,
          output_dir=output_dir,
          rel_dir=rel_dir,
          update_filepaths=update_filepaths,
          delete_originals=delete_originals,
          skip_failures=skip_failures,
          verbose=verbose,
          **kwargs,
      )
  
imports: import itertools
  import json
  import logging
  import os
  import eta.core.frameutils
  import eta.core.image
  import eta.core.numutils
  import eta.core.utils
  import eta.core.video
  import fiftyone
  import fiftyone.core.metadata
  import fiftyone.core.storage
  import fiftyone.core.utils
  import fiftyone.core.validation
label_desc: Use image node_id 2 for calling a global function with example usage: reencode_videos(sample_collection, force_reencode, media_field, output_field, output_dir, rel_dir, update_filepaths, delete_originals, skip_failures, verbose) without return types