| extract_audio | R Documentation |
Take one audio track out of infile, and drop the video. When the
input has more than one audio track, audio_stream names which one to
take. With no audio_stream, the function takes the first
audio track. The glossary in vignette("tidymedia") explains media
terms such as codec, container and stream copy.
extract_audio(
infile,
outfile,
audio_codec = "copy",
audio_stream = NULL,
run = TRUE
)
infile |
A string containing the path to a media file. |
outfile |
A string containing the path of the audio file to write. |
audio_codec |
A string naming the audio codec for the output stream.
The default |
audio_stream |
The audio track to take, as a number that counts from |
run |
A logical: run the command through FFmpeg ( |
When no audio_stream is named and the input has tracks that the output will not carry, the function warns. The check costs one FFprobe call per distinct input, which is one call here, because this function takes a single infile. The warning is given when FFprobe is available and the input can be probed. Otherwise the check is skipped silently. It never runs under run = FALSE, and never changes the compiled command. Suppress it by naming a track with audio_stream, or by class with suppressWarnings(classes = "tidymedia_dropped_audio").
To switch the check off and skip its FFprobe call, use options(tidymedia.check_tracks = FALSE) for the session. Use withr::local_options(tidymedia.check_tracks = FALSE) for the rest of one function.
The compiled FFmpeg command (invisibly when run = TRUE).
ffm_drop() and ffm_codec(), the pipeline functions it wraps.
convert_audio() to re-encode the extracted audio.
extract_audio_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_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(),
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_batch(),
format_for_web(),
format_for_web_batch(),
normalize_audio(),
normalize_audio_batch(),
picture_in_picture(),
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")
extract_audio(video, "audio.aac", run = FALSE)
# Take the second audio track instead of the first
extract_audio(video, "audio.aac", audio_stream = 1, run = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.