AVStream.duration

Decoding: duration of the stream, in stream time base. If a source file does not specify a duration, but does specify a bitrate, this value will be estimated from bitrate and file size.

struct AVStream
int64_t duration;

Meta