From patchwork Thu Apr 16 05:49:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 18995 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 86C6B449F1D for ; Thu, 16 Apr 2020 08:59:41 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5AFFD68BBDC; Thu, 16 Apr 2020 08:59:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4571968B7C3 for ; Thu, 16 Apr 2020 08:59:34 +0300 (EEST) Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 492pGC62Y9zKmmL for ; Thu, 16 Apr 2020 07:49:55 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id 7G1NKdQ19fe7 for ; Thu, 16 Apr 2020 07:49:52 +0200 (CEST) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Apr 2020 11:19:25 +0530 Message-Id: <20200416054926.1079-1-ffmpeg@gyani.pro> MIME-Version: 1.0 X-Rspamd-Queue-Id: B0D051782 X-Rspamd-Score: 0.29 / 15.00 / 15.00 Subject: [FFmpeg-devel] [PATCH v3] ffmpeg: allow full range of dts_delta_threshold 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" For inputs from demuxers with AVFMT_TS_DISCONT flag, the existing condition, delta < -1LL*dts_delta_threshold*AV_TIME_BASE is rendered superflous due to the fixed threshold in pkt_dts + AV_TIME_BASE/10 < FFMAX(ist->pts, ist->dts) This prevents users from setting a high threshold to avoid discontinuity correction due to errant timestamps. Now, if threshold is set by user, it is honoured, else existing behaviour is maintained. --- Tested with multiple satellite MPEG-TS inputs. fftools/ffmpeg.c | 13 ++++++++----- fftools/ffmpeg_opt.c | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0578265c1e..84a1e6543e 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -4439,8 +4439,9 @@ static int process_input(int file_index) pkt_dts != AV_NOPTS_VALUE && ist->next_dts == AV_NOPTS_VALUE && !copy_ts && (is->iformat->flags & AVFMT_TS_DISCONT) && ifile->last_ts != AV_NOPTS_VALUE) { int64_t delta = pkt_dts - ifile->last_ts; - if (delta < -1LL*dts_delta_threshold*AV_TIME_BASE || - delta > 1LL*dts_delta_threshold*AV_TIME_BASE){ + int64_t effective_threshold = !dts_delta_threshold ? 10*AV_TIME_BASE : dts_delta_threshold*AV_TIME_BASE; + if (delta < -1LL*effective_threshold || + delta > 1LL*effective_threshold){ ifile->ts_offset -= delta; av_log(NULL, AV_LOG_DEBUG, "Inter stream timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", @@ -4478,9 +4479,11 @@ static int process_input(int file_index) !disable_discontinuity_correction) { int64_t delta = pkt_dts - ist->next_dts; if (is->iformat->flags & AVFMT_TS_DISCONT) { - if (delta < -1LL*dts_delta_threshold*AV_TIME_BASE || - delta > 1LL*dts_delta_threshold*AV_TIME_BASE || - pkt_dts + AV_TIME_BASE/10 < FFMAX(ist->pts, ist->dts)) { + int64_t effective_delta_threshold = !dts_delta_threshold ? 10*AV_TIME_BASE : dts_delta_threshold*AV_TIME_BASE; + int64_t effective_negative_threshold = !dts_delta_threshold ? AV_TIME_BASE/10 : dts_delta_threshold*AV_TIME_BASE; + if (delta < -1LL*effective_delta_threshold || + delta > 1LL*effective_delta_threshold || + pkt_dts + effective_negative_threshold < FFMAX(ist->pts, ist->dts)) { ifile->ts_offset -= delta; av_log(NULL, AV_LOG_DEBUG, "timestamp discontinuity for stream #%d:%d " diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 93b3d96205..58fa1d7854 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -146,7 +146,7 @@ char *vstats_filename; char *sdp_filename; float audio_drift_threshold = 0.1; -float dts_delta_threshold = 10; +float dts_delta_threshold = 0; float dts_error_threshold = 3600*30; int audio_volume = 256;