Duration
Duration[expr]
returns the duration of expr.
Duration[expr,unit]
returns the result in the specified unit.
Details
- Duration can be computed on a variety of objects and entities that have an associated length of time.
- Some supported objects are:
-
Audio[samples] length of samples divided by sample rate DateInterval[{start,end}] duration between start and end DateObject[…] duration given by the object's granularity Entity[…] duration, based on start date, end date and more Sound[prims] computed from sound primitives prims Sound[prims,t] Sound[prims,{tmin,tmax}] SampledSoundList[{a1,…,an},r] SampledSoundFunction[f,n,r] SoundNote[spec] SoundNote[spec,t] SoundNote[spec,{tmin,tmax}] TimeObject[…] duration given by the object's granularity TimeSeries[…] difference between last time and first time Video[…] approximate duration of video, audio and subtitle tracks - By default, the unit of the result is automatically chosen to best represent the duration of expr. Use Duration[expr,unit] to specify a unit.
- The unit specification unit can be any of the following:
-
Automatic automatically determined unit unit any unit compatible with "Seconds" quantity any quantity with time units None duration in seconds returned as a real number
Examples
open allclose allBasic Examples (2)
Scope (10)
Input Data (8)
Duration of a Sound object:
A sound from a sequence of notes:
A Video object:
A TimeSeries object:
Duration of a financial time series:
Duration of an Entity:
Duration of a DateObject:
The result depends on the granularity of the input:
Duration of a TimeObject:
Applications (1)
Get the Audio duration in seconds:
Properties & Relations (4)
Duration automatically optimizes the unit of the result:
For Audio, dividing the number of samples by the sample rate is equivalent to the duration:
Audio duration can be computed by dividing the number of samples by the sample rate:
The duration of audio files can be imported directly from the file:
Compare with the duration of the imported audio:
Duration returns approximate duration for video files:
Compare with the "Duration" element in Import:
Get exact durations for all tracks using "ExactDurations" element:
Computing "Duration" is typically faster than computing "ExactDurations":
Text
Wolfram Research (2016), Duration, Wolfram Language function, https://reference.wolfram.com/language/ref/Duration.html (updated 2023).
CMS
Wolfram Language. 2016. "Duration." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2023. https://reference.wolfram.com/language/ref/Duration.html.
APA
Wolfram Language. (2016). Duration. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Duration.html