Given a vector of paths to images (preferably .jpg
s
or .png
s) and a flat list of Wave
s of equal
length this function will create an .mp4
video file where each image
is shown with its corresponding audio. Take a look at the
readWave
function if you want to import your audio
files into R. Please be sure that all images have the same dimensions.
ari_stitch(
images,
audio,
output = tempfile(fileext = ".mp4"),
verbose = FALSE,
cleanup = TRUE,
ffmpeg_opts = "",
divisible_height = TRUE,
audio_codec = get_audio_codec(),
video_codec = get_video_codec(),
video_sync_method = "2",
audio_bitrate = NULL,
video_bitrate = NULL,
pixel_format = "yuv420p",
fast_start = TRUE,
deinterlace = TRUE,
stereo_audio = TRUE
)
A vector of paths to images.
A list of Wave
s from tuneR.
A path to the video file which will be created.
print diagnostic messages. If > 1, then more are printed
If TRUE
, interim files are deleted
additional options to send to ffmpeg
.
This is an advanced option, use at your own risk
Make height divisible by 2, which may be required if getting "height not divisible by 2" error.
The audio encoder for the splicing. If this
fails, try copy
.
The video encoder for the splicing. If this
fails, see ffmpeg -codecs
Video sync method. Should be "auto" or `"vfr"` or a numeric. See https://ffmpeg.org/ffmpeg.html.
Bit rate for audio. Passed to -b:a
.
Bit rate for video. Passed to -b:v
.
pixel format to encode for `ffmpeg`.
Adding `faststart` flags for YouTube and other sites, see https://trac.ffmpeg.org/wiki/Encode/YouTube
should the video be de-interlaced, see https://ffmpeg.org/ffmpeg-filters.html, generally for YouTube
should the audio be forced to stereo, corresponds to `-ac 2`
A logical value, with the attribute outfile
for the
output file.
This function uses FFmpeg
which you should be sure is installed before using this function. If running
Sys.which("ffmpeg")
in your R console returns an empty string after
installing FFmpeg then you should set the path to FFmpeg on you computer to
an environmental variable using Sys.setenv(ffmpeg = "path/to/ffmpeg")
.
The environmental variable will always override the result of
Sys.which("ffmpeg")
.
# NOT RUN {
if (ffmpeg_version_sufficient()) {
result = ari_stitch(
ari_example(c("mab1.png", "mab2.png")),
list(tuneR::noise(), tuneR::noise()))
}
# }
Run the code above in your browser using DataLab