diff --git a/libavformat/demux.c b/libavformat/demux.c index 4e983f0703..3cc48fd49e 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -1265,7 +1265,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, /* set the duration */ out_pkt->duration = (sti->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) ? pkt->duration : 0; if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { - if (sti->avctx->sample_rate > 0 && sti->parser->duration > 0) { + if (sti->avctx->sample_rate > 0 && !out_pkt->duration && sti->parser->duration > 0) { out_pkt->duration = av_rescale_q_rnd(sti->parser->duration, (AVRational) { 1, sti->avctx->sample_rate }, diff --git a/tests/ref/fate/matroska-encoding-delay b/tests/ref/fate/matroska-encoding-delay index cfa1675b94..31d00882a4 100644 --- a/tests/ref/fate/matroska-encoding-delay +++ b/tests/ref/fate/matroska-encoding-delay @@ -21,7 +21,7 @@ ece637ed28526724c88f5c69b8bf7d6f *tests/data/fate/matroska-encoding-delay.matros 1, 86, 86, 24, 1152, 0xc9e85398 1, 110, 110, 24, 1152, 0xda1287d3 0, 120, 120, 40, 238290, 0xbe18b18f -1, 134, 134, 24, 1152, 0x1c9a6102 +1, 134, 134, 16, 1152, 0x1c9a6102 [PACKET] codec_type=audio stream_index=1 diff --git a/tests/ref/fate/matroska-flac-channel-mapping b/tests/ref/fate/matroska-flac-channel-mapping index 25627d6570..91a778853f 100644 --- a/tests/ref/fate/matroska-flac-channel-mapping +++ b/tests/ref/fate/matroska-flac-channel-mapping @@ -16,16 +16,16 @@ 1, 4096, 4096, 4096, 26, 0x50d30416 0, 8192, 8192, 4096, 26, 0x51ee046f 1, 8192, 8192, 4096, 26, 0x51ee046f -0, 12288, 12288, 4096, 26, 0x521d0458 -1, 12288, 12288, 4096, 26, 0x521d0458 +0, 12288, 12288, 4097, 26, 0x521d0458 +1, 12288, 12288, 4097, 26, 0x521d0458 0, 16385, 16385, 4096, 26, 0x531c043d 1, 16385, 16385, 4096, 26, 0x531c043d 0, 20481, 20481, 4096, 26, 0x53cf0442 1, 20481, 20481, 4096, 26, 0x53cf0442 0, 24577, 24577, 4096, 26, 0x536a0473 1, 24577, 24577, 4096, 26, 0x536a0473 -0, 28673, 28673, 4096, 26, 0x5321046c -1, 28673, 28673, 4096, 26, 0x5321046c +0, 28673, 28673, 4097, 26, 0x5321046c +1, 28673, 28673, 4097, 26, 0x5321046c 0, 32770, 32770, 4096, 26, 0x51b00449 1, 32770, 32770, 4096, 26, 0x51b00449 0, 36866, 36866, 4096, 26, 0x518b042e