[FFmpeg-devel] [PATCH] avcodec: Fix duration error after seek operation
王兴超
wangxingchao at xiaomi.com
Fri Nov 15 09:14:32 CET 2013
Hi Michael/Justin,
I met a "duration set" bug in cook parser when seeking, the first audio packet always dropped as its pts/dts be AV_NOPTS_VALUE.
After some investigation, the root cause is AVCodecParserContext 's duration was forgot set after duration calculation. The attached
patch could fix this issue and i verify it with latest commit, pls feel free to let me know if there's potential issue.
thanks
--xingchao
________________________________________
From: wangxingchao [wangxingchao at xiaomi.com]
Sent: Friday, November 15, 2013 4:03 PM
To: 王兴超
Subject: [PATCH] avcodec: Fix duration error after seek operation
After seek, s->duration need recalculation, AVCodecParserContext need be set
again. Without the fix, the first audio packet would be dropped after
compute_pkt_fields() as the final pts/dts become invalid.
Signed-off-by: wangxingchao <wangxingchao at xiaomi.com>
---
libavcodec/cook_parser.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libavcodec/cook_parser.c b/libavcodec/cook_parser.c
index f17f56e..fed9419 100644
--- a/libavcodec/cook_parser.c
+++ b/libavcodec/cook_parser.c
@@ -40,11 +40,12 @@ static int cook_parse(AVCodecParserContext *s1, AVCodecContext *avctx,
{
CookParseContext *s = s1->priv_data;
- if (s->duration)
- s1->duration = s->duration;
- else if (avctx->extradata && avctx->extradata_size >= 8 && avctx->channels)
+ if (!s->duration &&
+ avctx->extradata && avctx->extradata_size >= 8 && avctx->channels)
s->duration = AV_RB16(avctx->extradata + 4) / avctx->channels;
+ s1->duration = s->duration;
+
/* always return the full packet. this parser isn't doing any splitting or
combining, only setting packet duration */
*poutbuf = buf;
--
1.7.9.5
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-avcodec-Fix-duration-error-after-seek-operation.patch
Type: text/x-patch
Size: 1385 bytes
Desc: 0001-avcodec-Fix-duration-error-after-seek-operation.patch
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131115/ae697947/attachment.bin>
More information about the ffmpeg-devel
mailing list