Skip to contents

Combine multiple video files one after another without needing to re-encode them by using the concat demuxer. This will be much faster than re-encoding but requires that the files have the same parameters (width, height, etc.) and formats/codecs. To concatenate videos using re-encoding, see the concat video filter. The glossary in vignette("tidymedia") explains media terms such as codec and re-encode.

Usage

concatenate_videos(infiles, outfile, run = TRUE)

Arguments

infiles

A character vector containing the file paths to video files. This function checks every path itself. A path that cannot be found or read aborts naming this function, and the error lists every such path. It is not reported against the internal builder that the path would otherwise reach.

outfile

A string containing the desired file path to write the new, concatenated video file to.

run

A logical: run the command through FFmpeg (TRUE, default) or return the compiled command without running it (FALSE).

Value

The compiled FFmpeg command (invisibly when run = TRUE).

Examples

video <- system.file("extdata", "sample.mp4", package = "tidymedia")
concatenate_videos(c(video, video), "joined.mp4", run = FALSE)
#> [1] "-y -f concat -safe 0 -i \"/tmp/RtmpTo1HDT/ffm-concat1eeb12002f41.txt\" -codec:v copy -codec:a copy -map \"0\" \"joined.mp4\""