| picture_in_picture | R Documentation |
Composite a smaller overlay video onto a main video in one
corner (or the center). This is the classic picture-in-picture layout for
pairing a speaker with a screen recording, or a stimulus with a webcam. Built
on the ffm_overlay pipeline function, which resizes the overlay
to a fraction of the main video's width and positions it. The glossary in
vignette("tidymedia") explains media terms such as codec, encoder and
stream copy.
picture_in_picture(
main,
overlay,
outfile,
position = c("topright", "topleft", "bottomright", "bottomleft", "center"),
scale = 0.25,
margin = 16,
audio_input = NULL,
video_codec = NULL,
audio_codec = "copy",
hardware = c("none", "nvenc", "videotoolbox"),
fallback = FALSE,
quality = NULL,
run = TRUE
)
main |
A string giving the path to the background (full-size) video. |
overlay |
A string giving the path to the inset video. |
outfile |
A string giving the path to write the result to. |
position |
Where to place the inset: one of |
scale |
The inset's width as a fraction of the main video's width, aspect
preserved ( |
margin |
The gap in pixels between the inset and the video edges (ignored
for |
audio_input |
The input file whose audio to keep, as a number that counts from |
video_codec |
A string naming the output video codec, or |
audio_codec |
A string naming the codec for the carried audio track.
|
hardware |
The encoder backend. |
fallback |
A logical. When a |
quality |
A number, or |
run |
A logical: run the command through FFmpeg ( |
Audio is dropped unless audio_input names an input to carry (0 = the
main video, 1 = the overlay). A carried track is
stream-copied unless audio_codec names an encoder.
The compiled FFmpeg command (invisibly when run = TRUE).
ffm_overlay(), the pipeline function it wraps;
has_hardware_encoder() for the
hardware argument; compare_videos() for
side-by-side stacking.
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_batch(),
sample_frames(),
sample_frames_batch(),
segment_video(),
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_batch(),
segment_video(),
segment_video_batch(),
separate_audio_video(),
separate_audio_video_batch(),
standardize_video(),
standardize_video_batch()
video <- system.file("extdata", "sample.mp4", package = "tidymedia")
picture_in_picture(video, video, "pip.mp4", run = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.