Duration is the length of time that something lasts. In a media file, duration means the total running time. Video duration means how long a video plays from start to end, and audio duration means the same for a song or a recording.
You usually see this number in your media player as the total time. In metadata, the same information appears in a field named Duration.
Which files carry it
Duration belongs to files that play over time, which means audio and video files. Still photos and text documents normally have no duration field.
Animated images are a special case. A GIF file stores a delay for each frame and no total time. ExifTool still reports a Duration for one pass of the animation.
Where the value comes from
Some formats store the length directly. Other formats store values that software uses to calculate the length.
- MP4 and MOV: the movie header stores a time scale and a duration. The time scale is the number of time units per second, and the duration counts those units.
- MKV and WebM: the segment information can hold an optional
Durationelement, counted in ticks. By default, one tick is one millisecond. - MP3: the ID3 tag can hold a
TLENframe with the length in milliseconds. ExifTool calculates the length from other values, such as the file size and the bit rate. - FLAC: the file stores the total number of samples and the sample rate. Software calculates the length from these 2 values, and a total of
0means the number is unknown. - WAV: ExifTool calculates the length from the average bytes per second and the file size.
What the values look like
The same length can appear in different forms, depending on the program that reads the file:
00:05:15: hours, minutes, and seconds. This file runs for 5 minutes and 15 seconds.15.23 s: seconds, with the unit shown.200.541000: a number with no unit. The ffprobe program from the FFmpeg project prints the duration this way, with 6 digits after the decimal point. The number means 200.541 seconds, about 3 minutes and 21 seconds.N/A: in its default output format, ffprobe prints this when the duration is missing. The JSON and XML output formats leave the duration out instead.
A number with no unit is not always in seconds. The TLEN frame counts milliseconds, and the duration_ts value in ffprobe counts units of the stream's time base. Check which field gave you the number.
Why programs can show different durations
Different programs can show different durations for the same file, and neither program has to be wrong. Here are 4 reasons:
- Rounding: a player that shows only whole seconds rounds
200.541up or down. - Separate tracks: the picture and the sound have separate tracks, and each track has its own duration. In a MOV file, the movie duration corresponds to the longest track.
- Start times: each stream can have its own start time. FFmpeg can measure from the earliest start to the latest end, so a late start can make the total longer.
- Estimates: a file can have a bit rate but no duration. FFmpeg then estimates the duration from the bit rate and the file size, and warns that the result may be inaccurate.
Why it matters
Duration lets you check a file without playing it. If you expect a clip of 5 minutes and 15 seconds and see 15.23 s, the file may not be the one you expected.
Duration also connects to other values. FFmpeg can calculate the overall bit rate from the file size and the duration.