Extract a Time Range from a Media File
Description
Cut [start, start + duration] (or [start, end]) out of an audio
or video file via ffmpeg. Re-encodes by default for frame-accurate cuts; set
reencode = FALSE for a fast stream copy (cuts land on keyframes).
Usage
subclip(input, output, start = 0, duration = NULL, end = NULL, reencode = TRUE,
overwrite = TRUE, dry_run = FALSE)
Arguments
input: Path to input media.output: Path for the extracted output; extension selects the format.start: Start time in seconds (default 0).duration: Length in seconds, or NULL to useendor run to the end of the file.end: End time in seconds (ignored whendurationis set).reencode: If TRUE (default), re-encode for accurate cuts; if FALSE, stream-copy (fast, keyframe-aligned).overwrite: If TRUE (default), overwrite the output file.dry_run: If TRUE, return the ffmpeg command without executing.
Value
Invisibly returns the output path. If dry_run, returns the command string.
Examples
subclip("audio.mp3", "chunk.mp3", start = 2.14, duration = 5.0)
subclip("clip.mp4", "head.mp4", start = 0, end = 3, reencode = FALSE)