'AVStream.duration has a wrong value

I'm trying to get to the end of my video stream.

But AVStream.duration gives a wrong value, and I have to use av_rescale_q to convert AV_TIME_BASE timestamp from FormatContext.duration to stream time_base timestamp.

print("{}\n", formatCtx->streams[videoStreamIndex]->duration);
current_frame_timestamp = av_rescale_q(formatCtx->duration, AV_TIME_BASE_Q, formatCtx->streams[videoStreamIndex]->time_base);
print("{}\n", current_frame_timestamp);

-9223372036854775808
3653000


Solution 1:[1]

-9223372036854775808 is probably AV_NOPTS_VALUE which means no pts/dts present (or invalid).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 the kamilz