| segment_video | R Documentation |
Use FFmpeg to quickly break a single video file into multiple smaller video
files (with the same encoding). Pairs of start and stop timestamps set the
segments. The function names each segment file after infile. It
appends a suffix of an underscore (_) and an integer indicating which
segment, based on the order provided in start and end. The
glossary in vignette("tidymedia") explains media terms such as codec,
keyframe and stream copy.
segment_video(
infile,
start,
end,
outfiles = NULL,
reencode = TRUE,
video_codec = NULL,
audio_codec = "copy",
hardware = c("none", "nvenc", "videotoolbox"),
fallback = FALSE,
quality = NULL,
audio_stream = NULL,
run = TRUE,
parallel = FALSE
)
infile |
A string containing the path to a video file. |
start |
A vector containing one or more timestamps indicating the
start of each segment to create. Can be either a numeric vector indicating
seconds or a character vector with time duration syntax. Must have the same
length as |
end |
A vector containing one or more timestamps indicating the stop
of each segment to create. Can be either a numeric vector indicating
seconds or a character vector with time duration syntax. Must have the same
length as |
outfiles |
Either NULL or a character vector indicating the filename
(with extension) for each segment to create. If NULL, will append a
zero-padded integer to |
reencode |
A logical passed to |
video_codec |
A string naming the output video codec, or |
audio_codec |
A string naming the output audio codec.
|
hardware |
The encoder backend. |
fallback |
A logical. When a |
quality |
A number, or |
audio_stream |
The audio track to carry into the output, as a number that counts from |
run |
A logical: run each segment's command ( |
parallel |
A logical passed to |
The tibble returned by
ffm_batch: one row per segment with its command (and,
when run = TRUE, success).
https://ffmpeg.org/ffmpeg-utils.html#time-duration-syntax
ffm_seek(), the pipeline function it uses to cut; ffm_batch(),
the runner; has_hardware_encoder() for the hardware argument;
segment_video_batch() for the many-file form.
Other task functions:
anonymize_video(),
anonymize_video_batch(),
compare_videos(),
compare_videos_batch(),
concatenate_videos(),
concatenate_videos_batch(),
convert_audio(),
convert_audio_batch(),
crop_video(),
crop_video_batch(),
extract_audio(),
extract_audio_batch(),
extract_frame(),
extract_frame_batch(),
format_for_web(),
format_for_web_batch(),
normalize_audio(),
normalize_audio_batch(),
picture_in_picture(),
picture_in_picture_batch(),
sample_frames(),
sample_frames_batch(),
segment_video_batch(),
separate_audio_video(),
separate_audio_video_batch(),
standardize_video(),
standardize_video_batch(),
strip_metadata(),
strip_metadata_batch()
Other audio selection functions:
anonymize_video(),
anonymize_video_batch(),
audio_stream,
compare_videos(),
compare_videos_batch(),
convert_audio(),
convert_audio_batch(),
crop_video(),
crop_video_batch(),
extract_audio(),
extract_audio_batch(),
format_for_web(),
format_for_web_batch(),
normalize_audio(),
normalize_audio_batch(),
picture_in_picture(),
picture_in_picture_batch(),
segment_video_batch(),
separate_audio_video(),
separate_audio_video_batch(),
standardize_video(),
standardize_video_batch()
video <- system.file("extdata", "sample.mp4", package = "tidymedia")
# Two segments; run = FALSE compiles one command per segment
segment_video(video, start = c(0, 0.5), end = c(0.5, 1), run = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.