Title: | R Bindings to the editly NodeJS Package |
---|---|
Description: | R bindings to the editly NodeJS, for declarative video editing <https://github.com/mifi/editly/>. |
Authors: | Ben Raymond [aut, cre], Adrien Ickowicz [aut] |
Maintainer: | Ben Raymond <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.4 |
Built: | 2024-11-01 11:16:52 UTC |
Source: | https://github.com/scienceuntangled/editry |
R bindings to the editly NodeJS, for declarative video editing https://github.com/mifi/editly/.
If ffmpeg
can already be seen by the system, the system path will not be changed. Otherwise, the system path will be prepended with the ffmpeg path.
er_add_ffmpeg_path()
er_add_ffmpeg_path()
TRUE
on success, invisibly
The difference between er_audio_track
and er_layer_audio()
is that an er_audio_track
will continue to play across multiple clips and can start and stop whenever needed.
er_audio_track(path, cut_from, cut_to, start, mix_volume)
er_audio_track(path, cut_from, cut_to, start, mix_volume)
path |
string: path to audio file |
cut_from |
numeric: time value to cut from, in seconds |
cut_to |
numeric: time value to cut to, in seconds |
start |
numeric: how many seconds into the video should this audio track start? (default = 0) |
mix_volume |
numeric: relative volume when mixing this video's audio track with others (default = 1) |
A list of class er_audio_track
https://github.com/mifi/editly/
Does not require node or editly to be installed on your system, instead requires that Docker is running and that you have pulled a suitable editly docker image. By default this is scienceuntangled/editly
, which uses a modified version of editly
. Other editly
docker images can be used, but will not support the logo_*
parameters in er_header
or er_spec
.
er_exec_docker( spec, docker_image = "scienceuntangled/editly", fast = FALSE, extra_docker_args )
er_exec_docker( spec, docker_image = "scienceuntangled/editly", fast = FALSE, extra_docker_args )
spec |
er_spec: an |
docker_image |
string: name of the docker image to use |
fast |
logical: if |
extra_docker_args |
character: additional arguments to pass to the |
0 for success (invisibly)
https://github.com/mifi/editly/
## Not run: clips <- list(er_clip_title2(duration = 3, text = "Title slide"), er_clip_image(duration = 3, path = "https://jeroen.github.io/images/Rlogo.png")) outfile <- tempfile(fileext = ".mp4") my_spec <- er_spec(clips = clips , out_path = outfile, allow_remote_requests = TRUE) er_exec_docker(my_spec) if (interactive()) browseURL(outfile) ## End(Not run)
## Not run: clips <- list(er_clip_title2(duration = 3, text = "Title slide"), er_clip_image(duration = 3, path = "https://jeroen.github.io/images/Rlogo.png")) outfile <- tempfile(fileext = ".mp4") my_spec <- er_spec(clips = clips , out_path = outfile, allow_remote_requests = TRUE) er_exec_docker(my_spec) if (interactive()) browseURL(outfile) ## End(Not run)
Execute editly
er_exec_wait(spec, fast = FALSE, ...)
er_exec_wait(spec, fast = FALSE, ...)
spec |
er_spec or string: |
fast |
logical: if |
... |
: if a JSON file is not being used, you can provide command line arguments as individual parameters |
0 for success (invisibly)
https://github.com/mifi/editly/
## Not run: clips <- list(er_clip_title2(duration = 3, text = "Title slide"), er_clip_image(duration = 3, path = "https://jeroen.github.io/images/Rlogo.png")) outfile <- tempfile(fileext = ".mp4") my_spec <- er_spec(clips = clips , out_path = outfile, allow_remote_requests = TRUE) er_exec_wait(my_spec) if (interactive()) browseURL(outfile) ## End(Not run)
## Not run: clips <- list(er_clip_title2(duration = 3, text = "Title slide"), er_clip_image(duration = 3, path = "https://jeroen.github.io/images/Rlogo.png")) outfile <- tempfile(fileext = ".mp4") my_spec <- er_spec(clips = clips , out_path = outfile, allow_remote_requests = TRUE) er_exec_wait(my_spec) if (interactive()) browseURL(outfile) ## End(Not run)
Path to the ffmpeg executable
er_ffmpeg_exe()
er_ffmpeg_exe()
The path to the executable, or NULL
if not found
er_ffmpeg_exe()
er_ffmpeg_exe()
Editry requires that editly
(the underlying nodeJS package) be available on your system, along with node
and ffmpeg
. These can either be installed directly on your system, or in a docker image. er_install_editly
will attempt to install node
, ffmpeg
, and editly
directly on your system. See the package overview at https://scienceuntangled.github.io/editry for docker-based installation.
er_install_editly(force = FALSE, dependencies = TRUE)
er_install_editly(force = FALSE, dependencies = TRUE)
force |
logical: if |
dependencies |
logical: if |
The path to the installation (invisibly)
https://github.com/scienceuntangled/editly/
This is a helper function to install ffmpeg. Currently it only works on Windows and Linux platforms. The ffmpeg bundle will be downloaded from https://github.com/BtbN/FFmpeg-Builds/releases/latest (Windows) or https://johnvansickle.com/ffmpeg/ (Linux) and saved to your user appdata directory.
er_install_ffmpeg(force = FALSE, bits, check_hash = TRUE)
er_install_ffmpeg(force = FALSE, bits, check_hash = TRUE)
force |
logical: force reinstallation if ffmpeg already exists |
bits |
integer: 32 or 64, for 32- or 64-bit install. If missing or |
check_hash |
logical: don't check the hash of the downloaded file. Ignored on windows |
the path to the installed executable
https://github.com/BtbN/FFmpeg-Builds/releases/latest https://johnvansickle.com/ffmpeg/
## Not run: er_install_ffmpeg() ## End(Not run)
## Not run: er_install_ffmpeg() ## End(Not run)
Create various sections of an editly spec
er_layer(type, ...) er_clip(duration, transition, layers) er_defaults(transition, layer, layer_type) er_header( out_path = tempfile(fileext = ".mp4"), fps, width, height, allow_remote_requests, audio_file_path, loop_audio, keep_source_audio, clips_audio_volume, output_volume, audio_norm.enable, audio_norm.gauss_size, audio_norm.max_gain, defaults, custom_output_args, logo_path, logo_width, logo_height, logo_x, logo_y )
er_layer(type, ...) er_clip(duration, transition, layers) er_defaults(transition, layer, layer_type) er_header( out_path = tempfile(fileext = ".mp4"), fps, width, height, allow_remote_requests, audio_file_path, loop_audio, keep_source_audio, clips_audio_volume, output_volume, audio_norm.enable, audio_norm.gauss_size, audio_norm.max_gain, defaults, custom_output_args, logo_path, logo_width, logo_height, logo_x, logo_y )
type |
string: the layer type (e.g. "title", "image", "video") |
... |
: other parameters |
duration |
numeric: duration in seconds |
transition |
list: an |
layers |
list: a list of |
layer |
list: default layer spec |
layer_type |
list: default layerType spec |
out_path |
string: the path of the video file to create (the file extension can be a video file extension or ".gif") |
fps |
numeric: frames per second (default = 25 or FPS of first video) |
width |
integer: video width (default = 640) |
height |
integer: auto based on width and aspect ratio of first video |
allow_remote_requests |
logical: allow remote URLs as paths? (default = |
audio_file_path |
string: set an audio track for the whole video |
loop_audio |
logical: loop the audio track if it is shorter than video? (default = |
keep_source_audio |
logical: keep source audio from clips? (default = |
clips_audio_volume |
numeric: volume of audio from clips relative to |
output_volume |
numeric or string: adjust output volume (final stage). e.g. 0.5 or "10dB" (default = 1) |
audio_norm.enable |
logical: enable audio normalization? (default = |
audio_norm.gauss_size |
numeric: audio normalization gauss size (default = 5) |
audio_norm.max_gain |
numeric: audio normalization max gain (default = 30) |
defaults |
er_defaults: as returned by |
custom_output_args |
character: vector of custom output codec/format arguments for ffmpeg |
logo_path |
string: path to logo file. This must be a local file, even if |
logo_width |
numeric: width of logo relative to screen width (0 to 1, default = 0.2). If only one of logo height or width is specified, the logo aspect ratio will be retained |
logo_height |
numeric: height of logo relative to screen width (0 to 1, default = 0.1). If only one of logo height or width is specified, the logo aspect ratio will be retained |
logo_x |
numeric: logo left-hand-edge position relative to left of screen (0 = left to 1 = right, default = 0.78). The logo is referenced relative to its left-hand edge, so the default of 0.78 and width 0.2 puts the right-hand edge at 0.98 |
logo_y |
numeric: logo bottom-edge position relative to top of screen (0 = top to 1 = bottom, default = 0.98) |
A list with class er_clip
, er_layer
, etc
https://github.com/mifi/editly/
position can be one of either:
top, bottom center, top-left, top-right, center-left, center-right, bottom-left, bottom-right
a list object x, y, originX = 'left', originY = 'top' , where x: 0, y: 0 is the upper left corner of the screen, and x: 1, y: 1 is the lower right corner, x is relative to video width, y to video height. originX and originY are optional, and specify the position's origin (anchor position) of the object.
er_layer_pause(color) er_layer_image(path, resize_mode, zoom_direction, zoom_amount) er_layer_image_overlay( path, position, width, height, zoom_direction, zoom_amount ) er_layer_title( text, font_path, text_color, position, zoom_direction, zoom_amount ) er_layer_subtitle(text, font_path, text_color) er_layer_title_background(text, font_path, text_color, background) er_layer_news_title( text, font_path, font_size, text_color, background_color, position ) er_layer_slide_in_text( text, font_path, font_size, char_spacing, color, position ) er_layer_fill_color(color) er_layer_radial_gradient(colors) er_layer_linear_gradient(colors) er_layer_rainbow_colors() er_layer_video( path, resize_mode, cut_from, cut_to, width, height, left, top, origin_x, origin_y, mix_volume ) er_layer_audio(path, cut_from, cut_to, mix_volume) er_layer_detached_audio(path, cut_from, cut_to, start, mix_volume)
er_layer_pause(color) er_layer_image(path, resize_mode, zoom_direction, zoom_amount) er_layer_image_overlay( path, position, width, height, zoom_direction, zoom_amount ) er_layer_title( text, font_path, text_color, position, zoom_direction, zoom_amount ) er_layer_subtitle(text, font_path, text_color) er_layer_title_background(text, font_path, text_color, background) er_layer_news_title( text, font_path, font_size, text_color, background_color, position ) er_layer_slide_in_text( text, font_path, font_size, char_spacing, color, position ) er_layer_fill_color(color) er_layer_radial_gradient(colors) er_layer_linear_gradient(colors) er_layer_rainbow_colors() er_layer_video( path, resize_mode, cut_from, cut_to, width, height, left, top, origin_x, origin_y, mix_volume ) er_layer_audio(path, cut_from, cut_to, mix_volume) er_layer_detached_audio(path, cut_from, cut_to, start, mix_volume)
color |
string: slide color (default = random) |
path |
string: path to image or video file |
resize_mode |
: see Details |
zoom_direction |
string: "in", out", or "null" to disable |
zoom_amount |
numeric: amount to zoom (default = 0.1) |
position |
string or list: see Details |
width |
numeric: width (from 0 to 1) where 1 is screen width |
height |
numeric: height (from 0 to 1) where 1 is screen height |
text |
string: text to show |
font_path |
string: path to font |
text_color |
string: text color |
background |
er_layer: as returned by |
font_size |
numeric: font size |
background_color |
string: background color |
char_spacing |
numeric: character spacing |
colors |
character: vector of two colors (default = random) |
cut_from |
numeric: time value to cut from, in seconds |
cut_to |
numeric: time value to cut to, in seconds |
left |
numeric: X-position relative to screen width (0 to 1, default = 0) |
top |
numeric: Y-position relative to screen height (0 to 1, default = 0) |
origin_x |
numeric: X anchor ("left" or "right", default = "left") |
origin_y |
numeric: Y anchor ("top" or "bottom", default = "top") |
mix_volume |
numeric: relative volume when mixing this video's audio track with others (default = 1) |
start |
numeric: how many seconds into this clip should this audio track start? (default = 0) |
Audio layers will be mixed together. If cutFrom/cutTo is set, the resulting segment (cutTo-cutFrom) will be slowed/sped-up to fit clip.duration. The slow down/speed-up operation is limited to values between 0.5x and 100x.
er_layer_detached_audio
is a special case of audio_tracks
that makes it easier to start the audio relative to clips start times without having to calculate global start times. detached audio has the exact same properties as audio_tracks
, except start time is relative to the clip's start.
For video layers, if parent clip.duration is specified, the video will be slowed/sped-up to match clip.duration. If cutFrom/cutTo is set, the resulting segment (cutTo-cutFrom) will be slowed/sped-up to fit clip.duration. If the layer has audio, it will be kept (and mixed with other audio layers if present.)
resize_mode - How to fit image to screen. Can be one of:
"contain" - All the video will be contained within the frame and letterboxed
"contain-blur" - Like contain, but with a blurred copy as the letterbox
"cover" - Video be cropped to cover the whole screen (aspect ratio preserved)
"stretch" - Video will be stretched to cover the whole screen (aspect ratio ignored). Default is "contain-blur".
A list with class er_layer
https://github.com/mifi/editly/
Create a spec ready for compiling to video
er_spec( header, clips, audio_tracks, theme = "er_theme_default", as = "object", ... )
er_spec( header, clips, audio_tracks, theme = "er_theme_default", as = "object", ... )
header |
er_header: as returned by |
clips |
list: a list of |
audio_tracks |
list: a list of |
theme |
string: name of a theme function to apply, or |
as |
string: either "object" (return an object of class |
... |
: as for |
A list of class er_spec
or a JSON string
https://github.com/mifi/editly/
er_layer()
, er_to_json()
, er_exec_wait()
Themes in editry are a set of defaults that can be supplied to the er_header()
or er_spec()
functions.
er_theme_default()
er_theme_default()
The default theme currently uses:
white text, with 'PatuaOne' font face
black slide backgrounds for plain slides, and grey gradients for radial or linear gradient backgrounds
red background for news-title layers
resize_mode "contain" for images
An object of class er_defaults
Convert editly spec to JSON string
er_to_json(spec)
er_to_json(spec)
spec |
string: a JSON string as returned by |
A JSON string
A clip transitions is the outgoing transition from the clip.
er_transition(name, duration, audio_out_curve, audio_in_curve)
er_transition(name, duration, audio_out_curve, audio_in_curve)
name |
string: can be any of the transitions listed in https://gl-transitions.com/gallery, or "directional-left", "directional-right", "directional-up", "directional-down", "random", " dummy" |
duration |
numeric: duration in seconds |
audio_out_curve |
string: fade out curve in audio cross fades (default = "tri") |
audio_in_curve |
string: fade in curve in audio cross fades (default = "tri") |
A list with class er_transition
https://github.com/mifi/editly/