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.
Arguments
- object
An FFmpeg pipeline (
ffm) object created byffm_files()with more than one input file.
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.
See also
concatenate_videos(), the task function built on this function.
Other pipeline functions:
ffm_batch(),
ffm_codec(),
ffm_compile(),
ffm_copy(),
ffm_crop(),
ffm_drawbox(),
ffm_drop(),
ffm_files(),
ffm_fps(),
ffm_hstack(),
ffm_jobs(),
ffm_loudnorm(),
ffm_map(),
ffm_output_options(),
ffm_overlay(),
ffm_pixel_format(),
ffm_run(),
ffm_scale(),
ffm_seek(),
ffm_trim(),
ffm_vstack(),
print.tidymedia_ffm()
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\""