From 5c1fe2a4f3e559a0c6a010e48b0c225d01c1cd0a Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 5 Mar 2016 12:48:58 +0100 Subject: demux: delay bitrate calculation on packets with unknown timestamps Commit 503c6f7f essentially removed timestamps from "laces" (Block sub- divisions), which means many audio packets will have no timestamp. There's no reason why bitrate calculation can't just delayed to a point when the next timestamp is known. Fixes #2903 (no audio bitrate with mkv files). --- demux/demux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demux/demux.c b/demux/demux.c index bd3211a74a..a7241d9a9f 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -681,11 +681,11 @@ static struct demux_packet *dequeue_packet(struct demux_stream *ds) if (ts != MP_NOPTS_VALUE) ds->base_ts = ts; - if (pkt->keyframe) { + if (pkt->keyframe && ts != MP_NOPTS_VALUE) { // Update bitrate - only at keyframe points, because we use the // (possibly) reordered packet timestamps instead of realtime. double d = ts - ds->last_br_ts; - if (ts == MP_NOPTS_VALUE || ds->last_br_ts == MP_NOPTS_VALUE || d < 0) { + if (ds->last_br_ts == MP_NOPTS_VALUE || d < 0) { ds->bitrate = -1; ds->last_br_ts = ts; ds->last_br_bytes = 0; -- cgit v1.2.3