def transform_videos(
    sample_collection,
    fps=None,
    min_fps=None,
    max_fps=None,
    size=None,
    min_size=None,
    max_size=None,
    reencode=False,
    force_reencode=False,
    media_field="filepath",
    output_field=None,
    output_dir=None,
    rel_dir=None,
    update_filepaths=True,
    delete_originals=False,
    skip_failures=False,
    verbose=False,
    progress=None,
    **kwargs,
):
    """Transforms the videos in the sample collection according to the provided
    parameters using ``ffmpeg``.

    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>``.

    In addition to the size and frame rate parameters, if ``reencode == True``,
    the following basic ``ffmpeg`` command structure is used to re-encode the
    videos as H.264 MP4s::

        ffmpeg \\
            -loglevel error -vsync 0 -i $INPUT_PATH \\
            -c:v libx264 -preset medium -crf 23 -pix_fmt yuv420p -vsync 0 -an \\
            $OUTPUT_PATH

    .. 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`
        fps (None): an optional frame rate at which to resample the videos
        min_fps (None): an optional minimum frame rate. Videos with frame rate
            below this value are upsampled
        max_fps (None): an optional maximum frame rate. Videos with frame rate
            exceeding this value are downsampled
        size (None): an optional ``(width, height)`` for each frame. One
            dimension can be -1, in which case the aspect ratio is preserved
        min_size (None): an optional minimum ``(width, height)`` for each
            frame. A dimension can be -1 if no constraint should be applied.
            The frames are resized (aspect-preserving) if necessary to meet
            this constraint
        max_size (None): an optional maximum ``(width, height)`` for each
            frame. A dimension can be -1 if no constraint should be applied.
            The frames are resized (aspect-preserving) if necessary to meet
            this constraint
        reencode (False): whether to re-encode the videos as H.264 MP4s
        force_reencode (False): whether to re-encode videos whose parameters
            already satisfy the specified values
        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 transformed
        verbose (False): whether to log the ``ffmpeg`` commands that are
            executed
        progress (None): whether to render a progress bar (True/False), use the
            default value ``fiftyone.config.show_progress_bars`` (None), or a
            progress callback function to invoke instead
        **kwargs: keyword arguments for ``eta.core.video.FFmpeg(**kwargs)``
    """
    fov.validate_video_collection(sample_collection)

    _transform_videos(
        sample_collection,
        fps=fps,
        min_fps=min_fps,
        max_fps=max_fps,
        size=size,
        min_size=min_size,
        max_size=max_size,
        reencode=reencode,
        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,
        progress=progress,
        **kwargs,
    )
Transforms the videos in the sample collection according to the provided
    parameters using ``ffmpeg``.

    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>``.

    In addition to the size and frame rate parameters, if ``reencode == True``,
    the following basic ``ffmpeg`` command structure is used to re-encode the
    videos as H.264 MP4s::

        ffmpeg \
            -loglevel error -vsync 0 -i $INPUT_PATH \
            -c:v libx264 -preset medium -crf 23 -pix_fmt yuv420p -vsync 0 -an \
            $OUTPUT_PATH

    .. 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`
        fps (None): an optional frame rate at which to resample the videos
        min_fps (None): an optional minimum frame rate. Videos with frame rate
            below this value are upsampled
        max_fps (None): an optional maximum frame rate. Videos with frame rate
            exceeding this value are downsampled
        size (None): an optional ``(width, height)`` for each frame. One
            dimension can be -1, in which case the aspect ratio is preserved
        min_size (None): an optional minimum ``(width, height)`` for each
            frame. A dimension can be -1 if no constraint should be applied.
            The frames are resized (aspect-preserving) if necessary to meet
            this constraint
        max_size (None): an optional maximum ``(width, height)`` for each
            frame. A dimension can be -1 if no constraint should be applied.
            The frames are resized (aspect-preserving) if necessary to meet
            this constraint
        reencode (False): whether to re-encode the videos as H.264 MP4s
        force_reencode (False): whether to re-encode videos whose parameters
            already satisfy the specified values
        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 transformed
        verbose (False): whether to log the ``ffmpeg`` commands that are
            executed
        progress (None): whether to render a progress bar (True/False), use the
            default value ``fiftyone.config.show_progress_bars`` (None), or a
            progress callback function to invoke instead
        **kwargs: keyword arguments for ``eta.core.video.FFmpeg(**kwargs)``
    
fiftyone/utils/video.py