adjust_playback_time: Modify playback time of video

View source: R/vis-adjust_playback_time.r

adjust_playback_timeR Documentation

Modify playback time of video

Description

Speed up or slow down playback of video using FFmpeg software.

Usage

adjust_playback_time(scale_factor = 1, input, output_dir = getwd(),
  output = "new.mp4", overwrite = FALSE, ffmpeg = NA,
  diagnostic_mode = FALSE)

Arguments

scale_factor

multiplicative factor changes duration of video playback. See details.

input

character, path to video file (any FFmpeg supported file type- *.mp4, *.wmv, see make_frames)

output_dir

character, output directory, default is working directory

output

character, output file name

overwrite

logical, default is overwrite = TRUE

ffmpeg

A file path (characer) to FFmpeg executable. This argument is only needed if ffmpeg is not added to your system path. For Windows machines, path must point to 'ffmpeg.exe', located in the bin subfolder within the ffmpeg folder. For example on Windows machines, "C:\Users\Username\Documents\ffmpeg-3.4.1-win64-static\bin\ffmpeg.exe"). On Mac, path must point to 'ffmpeg' within the 'bin' subfolder "/home/directory/Documents/bin/ffmpeg". see make_video

diagnostic_mode

Logical (default = FALSE). If true, return value is a character vector with FFMPEG output.

Details

adjust_playback_time adjusts playback speed of video. scale_factor controls the magnitude of speed-up or slow-down by modifying the presentation timestamp of each video frame. For more information, see How to speed up/slow down a video. Values of scale_factor < 1 speed up playback and >1 slow down video. In addition to changing playback, function can change output format by specifying a different file extension in output.

Value

One video animation will be written to output_dir

Author(s)

Todd Hayden, Tom Binder, Chris Holbrook

Examples


## Not run: 

# load example frames 
frames <- system.file("extdata", "frames", package = "glatos")

# make video animation 
make_video(dir = frames, pattern = "%02d.png", output = "animation.mp4" )

# slow video down by a factor of 10 
path <- file.path(getwd(), "animation.mp4")
adjust_playback_time(scale_factor = 10, input = path)

# slow video down by a factor of 10 and change format of output video
adjust_playback_time(scale_factor = 10, input = path, output = "slow.wmv")

# speed up video 
adjust_playback_time(scale_factor=0.5, input = path, output = "faster.mp4")

## End(Not run)

jsta/glatos documentation built on July 11, 2022, 7:01 a.m.