Skip to contents

get_duration() uses the MediaInfo program to look up the duration of a media file. You choose the section of the file and the unit.

Usage

get_duration(
  file,
  section = c("General", "Video", "Audio"),
  unit = c("ms", "sec", "min", "hour")
)

Arguments

file

A character vector of one or more media file paths.

section

A string indicating the MediaInfo section from which to query the duration value. Can be either "General", "Video", or "Audio" (default = "General").

unit

A string indicating whether the duration should be returned in milliseconds ("ms"), seconds ("sec"), minutes ("min"), or hours ("hour") (default = "ms").

Value

A double vector (one per file) giving the duration of the specified section in the specified units.

Details

The function returns one number for each file. The probe_*() functions, mediainfo_query() and mediainfo_template() return tibbles instead.

See also

Examples

video <- system.file("extdata", "sample.mp4", package = "tidymedia")
get_duration(video, unit = "sec")
#> [1] 1