Skip to contents

Join the pipeline's input files one after another with FFmpeg's concat demuxer. Like ffm_hstack, this is a pipeline function for several inputs. It uses stream copy, so it is fast and lossless. But every input must share the same parameters, such as codec, resolution and frame rate. The glossary in vignette("tidymedia") explains media terms such as codec, re-encode and stream copy.

Usage

ffm_concat(object)

Arguments

object

An FFmpeg pipeline (ffm) object created by ffm_files() with more than one input file.

Value

object with an added instruction to concatenate the inputs.

Details

To join inputs with different parameters, you must re-encode with the concat filter. The package does not wrap that filter yet, so use ffmpeg.

The demuxer needs a list file that names the inputs. When you call ffm_concat(), it writes one to a temporary path and stores it in the pipeline, so the compiled command can refer to it. It also copies codecs and maps all streams, as ffm_copy would.

Examples

video <- system.file("extdata", "sample.mp4", package = "tidymedia")
# Join two inputs end-to-end (they must share codec/resolution/frame rate)
ffm_files(c(video, video), "output.mp4") |>
  ffm_concat() |>
  ffm_compile()
#> [1] "-y -f concat -safe 0 -i \"/tmp/RtmpTo1HDT/ffm-concat1eeb23fe0c0c.txt\" -codec:v copy -codec:a copy -map \"0\" \"output.mp4\""