From patchwork Fri Apr 19 22:03:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 12823 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 2AF22448902 for ; Sat, 20 Apr 2019 01:06:53 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0C3AC689D2F; Sat, 20 Apr 2019 01:06:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C0334680629 for ; Sat, 20 Apr 2019 01:06:45 +0300 (EEST) Received: by mail-wm1-f65.google.com with SMTP id v14so7626685wmf.2 for ; Fri, 19 Apr 2019 15:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hyFRGHIEbwoYzKBb9gJgfF4Ybyh+GJQS+v7u3vDXNDg=; b=vBWVh+ouZF7eKJq/Cr03NChpPsxPEyLIal4mlhJjoD/iCOLKlWadXsAQ9/XAVKOmoY TtjZKEVnY6bRfqxBCJn8T8Q956N70/7QYBwovaRmjgONPnW/zR+uxXpE2y3Wf3GcTSTd i84b3WWTudEbUWDFKsEtCsA+nDBRIscXIf2TaEEUKCQ4qyXvMRqJ8UDb/LI/tyGg0g+u 5SvZf5fr19dhBGi1RisCsQirMJm0U2s/1N9Gds+chRf2fIsLIRbixkZ5B+E8GwiHrgU5 HP3FcuUq+Xy08HBuxtL0tEBLPPCk7sbhjyKzb62DJI3Y03ySazPVGyTjAv8NHhy0iAmA 3cUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hyFRGHIEbwoYzKBb9gJgfF4Ybyh+GJQS+v7u3vDXNDg=; b=CGpxEwhDxiG4dMsI8vIQVkNK86is8jAxgmcwcW73roOhKpxALSSokDRKCBjZmsoOep 0emflFWgeCIv/X9Y0tDw2Bps0qR9zLBlUk1V39EvqqRRLCA2Ys6dwY+pQdxoXOoCopGW 6HhZrzRfyFYZrTb5F4jb3ZoKjlwFaTJxYcv9Lz5dJaSjvLf1iNkg8mR3DQi+8EaWG105 hN1n0RALdy69pKB1p0HIH4+Ky8su5gyJL/6ZSFQ7fyaJMBLP4bc4xQ9muzejZc/aO8qz RT5Q+jwo9/gQE9mkI3N/nZurvErZ7BrP7nuoYZQEZq3OPekZGD0W7ghDJf4aYwh2N/cZ mFhw== X-Gm-Message-State: APjAAAVK1MBso7nslhQICohU1z5LxbKRw6Qg+b8ADAGpi8XB3dzssW3t SI6v79il/DVdXUpECvrIeTnN2IxM66w= X-Google-Smtp-Source: APXvYqyp/oypZjILKx8sMejUH4kgFqLPMQbJwAOzLmrMlbtmrpR1onl9+u5EvStg7aKq18TKVbz0iw== X-Received: by 2002:a7b:c147:: with SMTP id z7mr4024454wmi.67.1555711605115; Fri, 19 Apr 2019 15:06:45 -0700 (PDT) Received: from localhost.localdomain (ipbcc08c44.dynamic.kabel-deutschland.de. [188.192.140.68]) by smtp.gmail.com with ESMTPSA id z11sm5650642wmf.12.2019.04.19.15.06.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Apr 2019 15:06:44 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 20 Apr 2019 00:03:16 +0200 Message-Id: <20190419220316.47392-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190419220316.47392-1-andreas.rheinhardt@gmail.com> References: <20190413133052.2668-1-andreas.rheinhardt@googlemail.com> <20190419220316.47392-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] lavf/webm_chunk: Correct duration if start time > 0 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Up until now, it was simply presumed that the first packet had a pts of zero; otherwise the duration of the first chunk was wrong. Signed-off-by: Andreas Rheinhardt --- libavformat/webm_chunk.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 391fee721a..d45ebfb1e5 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -52,7 +52,7 @@ typedef struct WebMChunkContext { int chunk_index; char *http_method; uint64_t duration_written; - int prev_pts; + int64_t prev_pts; ff_const59 AVOutputFormat *oformat; AVFormatContext *avf; } WebMChunkContext; @@ -124,6 +124,7 @@ static int webm_chunk_write_header(AVFormatContext *s) wc->oformat = av_guess_format("webm", s->url, "video/webm"); if (!wc->oformat) return AVERROR_MUXER_NOT_FOUND; + wc->prev_pts = AV_NOPTS_VALUE; ret = chunk_mux_init(s); if (ret < 0) @@ -211,9 +212,10 @@ static int webm_chunk_write_packet(AVFormatContext *s, AVPacket *pkt) int ret; if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { - wc->duration_written += av_rescale_q(pkt->pts - wc->prev_pts, - st->time_base, - (AVRational) {1, 1000}); + if (wc->prev_pts != AV_NOPTS_VALUE) + wc->duration_written += av_rescale_q(pkt->pts - wc->prev_pts, + st->time_base, + (AVRational) {1, 1000}); wc->prev_pts = pkt->pts; }