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.
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
mediainfo_parameter() for arbitrary MediaInfo fields, and
probe_all() to read information with FFprobe.
Other metadata functions:
get_frame_rate(),
get_height(),
get_sample_rate(),
get_width(),
mediainfo_parameter(),
mediainfo_query(),
mediainfo_template(),
probe_all(),
probe_container()
Examples
video <- system.file("extdata", "sample.mp4", package = "tidymedia")
get_duration(video, unit = "sec")
#> [1] 1