Skip to contents

Set the audio codec, the video codec, or both, for the output file. Use ffmpeg_codecs() to see a list of the codecs in your FFmpeg version. The glossary in vignette("tidymedia") explains media terms such as codec and stream copy.

Usage

ffm_codec(object, audio = NULL, video = NULL)

Arguments

object

An FFmpeg pipeline (ffm) object created by ffm_files().

audio

A string that names the audio codec, or NULL to set only the video codec. The default is NULL. See audio_stream for the two things that the name audio means in the pipeline functions, and for the input index audio_input.

video

A string that names the video codec, or NULL to set only the audio codec. The default is NULL.

Value

object with an added instruction to change the codecs.

References

https://ffmpeg.org/ffmpeg-codecs.html

Examples

video <- system.file("extdata", "sample.mp4", package = "tidymedia")
ffm_files(video, "output.mp4") |>
  ffm_codec(video = "libx264", audio = "aac") |>
  ffm_compile()
#> [1] "-y -i \"/home/runner/work/_temp/Library/tidymedia/extdata/sample.mp4\" -codec:v libx264 -codec:a aac \"output.mp4\""