Reverting video_timestamp increment logic which used pkt.duration. In some codecs (such as vp8), this approach breaks due to differences in the timebase vs the framerate. For example, if the timebase is an inverse of the FPS, everything works. But if the timebase is not, for example 1/1000000, this approach breaks.

This commit is contained in:
Jonathan Thomas
2021-07-03 17:01:55 -05:00
parent 0f2f2e1514
commit 9ca63b321a
2 changed files with 8 additions and 8 deletions

View File

@@ -768,12 +768,12 @@ void FFmpegReader::UpdateVideoInfo() {
// Check for valid duration (if found)
if (info.duration <= 0.0f && pFormatCtx->duration >= 0)
// Use the format's duration
info.duration = pFormatCtx->duration / AV_TIME_BASE;
info.duration = float(pFormatCtx->duration) / AV_TIME_BASE;
// Calculate duration from filesize and bitrate (if any)
if (info.duration <= 0.0f && info.video_bit_rate > 0 && info.file_size > 0)
// Estimate from bitrate, total bytes, and framerate
info.duration = (info.file_size / info.video_bit_rate);
info.duration = float(info.file_size) / info.video_bit_rate;
// No duration found in stream of file
if (info.duration <= 0.0f) {