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 = FALSE, deinterlace = FALSE, stereo_audio = TRUE, duration = NULL, video_filters = NULL )
images | A vector of paths to images. |
---|---|
audio | A list of |
output | A path to the video file which will be created. |
verbose | print diagnostic messages. If > 1, then more are printed |
cleanup | If |
ffmpeg_opts | additional options to send to |
divisible_height | Make height divisible by 2, which may be required if getting "height not divisible by 2" error. |
audio_codec | The audio encoder for the splicing. If this
fails, try |
video_codec | The video encoder for the splicing. If this
fails, see |
video_sync_method | Video sync method. Should be "auto" or `"vfr"` or a numeric. See https://ffmpeg.org/ffmpeg.html. |
audio_bitrate | Bit rate for audio. Passed to |
video_bitrate | Bit rate for video. Passed to |
pixel_format | pixel format to encode for `ffmpeg`. |
fast_start | Adding `faststart` flags for YouTube and other sites, see https://trac.ffmpeg.org/wiki/Encode/YouTube |
deinterlace | should the video be de-interlaced, see https://ffmpeg.org/ffmpeg-filters.html, generally for YouTube |
stereo_audio | should the audio be forced to stereo, corresponds to `-ac 2` |
duration | a vector of numeric durations for each audio
track. See |
video_filters | any options that are passed to |
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")
.
if (FALSE) { if (ffmpeg_version_sufficient()) { result = ari_stitch( ari_example(c("mab1.png", "mab2.png")), list(tuneR::noise(), tuneR::noise())) } }