From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id C951640577 for ; Tue, 21 Dec 2021 13:54:50 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 21A8D68AF69; Tue, 21 Dec 2021 15:54:22 +0200 (EET) Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E904268A921 for ; Tue, 21 Dec 2021 15:54:20 +0200 (EET) Received: by mail-lf1-f52.google.com with SMTP id g26so13694006lfv.11 for ; Tue, 21 Dec 2021 05:54:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DA8hT6RJYqezw3uqiFxtsp6o5kao2G6PRwqIa6ifWcI=; b=a9B+k5wA2g/lpbne0BrOP7Afsw9DxU9wMagcLoEtKA7HlB0Jq6tfKi9vZc6IeXAtJw 3f2RHiOm9ANLvUMopX9kpgo9Jiuuf+5P4sdDo9ITV63rNBFXy5XR3WmzdhgRRth5qF4C z9GGrBkWxG/SsmxDppTBaWksF8Y6HewA7dv3MevkpDbIXsbbdzOvW9HDbcpsCBez67bv 0aRwFGAteygnQRNlxd2mkP1ficbxMWRINJZxPv81mhB+BaSkIX8BpGxj4IR5GRYXsKKi F/xEuvj7kfcEwsWk3FJeHxYJuTpvayroHUT1awRCDQQ9nYGKCzpwskOyoDCQNfzw8RvE ro9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DA8hT6RJYqezw3uqiFxtsp6o5kao2G6PRwqIa6ifWcI=; b=nwacyptFktoxcwgvU4W8ULsUZxO+t6P9rwsFLFku65cmG8CLvhIyIAHJVDyl1z/lnL mWkRKWvM7hX7aibmvGOeDWNI8H81gLdxEKAnJVVrVl/fMT7NxTUmkLFF1UyWdnLWnyk1 txBThr/rQEi6/siRp6u+yNCYLUCGwvWAcKh9zTUOOgCYfAXW5xVj+fcK035yfPH0ZyYx 44p2ple1egV8b3ntqcZFUWrUzAgs+AnKSY1gq0AU611E8BRd8CQch6eo4/m8u2mnbaeT r2X19RiEnjPO1Oyl7ZZTWKU3qrEYTZu5r3pA5ZeqFb022CqPnw4UXePpUN1uyCCmPDcn 7Sdw== X-Gm-Message-State: AOAM531NlwTPclo65H1htzKgloynb3qhnIn2wkbtxdf4TbZaO/1t4sBh 90d48PLwJU7XkuRB9ExXAkFxwmAT0hrzXg== X-Google-Smtp-Source: ABdhPJzZIh0hf8zVEuRBu/0QB8F5YcODpQf/4ZBExkHdBr8goIBHi7tUT1zxvPe1OQ9JsZ9jl71zVw== X-Received: by 2002:a05:6512:39ca:: with SMTP id k10mr1955847lfu.496.1640094859751; Tue, 21 Dec 2021 05:54:19 -0800 (PST) Received: from localhost.localdomain ([196.244.192.13]) by smtp.gmail.com with ESMTPSA id u23sm2750910lji.56.2021.12.21.05.54.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 05:54:19 -0800 (PST) From: Diederick Niehorster To: ffmpeg-devel@ffmpeg.org Date: Tue, 21 Dec 2021 14:53:29 +0100 Message-Id: <20211221135337.1348-5-dcnieho@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20211221135337.1348-1-dcnieho@gmail.com> References: <20211221135337.1348-1-dcnieho@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v7 04/12] avdevice/dshow: handle unknown sample time X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Diederick Niehorster Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: GetTime may return an error indication that the sample has not timestamps, or may return a NULL start time. In those cases, fall back to graph time. Emit log when that happens. Improve logging in the frame receive function: now logged against correct avclass instead of NULL. Better debug message in case sample dropped: could now be audio or video frame. Signed-off-by: Diederick Niehorster --- libavdevice/dshow_pin.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/libavdevice/dshow_pin.c b/libavdevice/dshow_pin.c index 1d0e880480..2d1fa0e882 100644 --- a/libavdevice/dshow_pin.c +++ b/libavdevice/dshow_pin.c @@ -295,14 +295,15 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) uint8_t *buf; int buf_size; /* todo should be a long? */ int index; - int64_t chosentime; - int64_t sampletime; - int64_t graphtime; + int64_t chosentime = 0; + int64_t sampletime = 0; + int64_t graphtime = 0; int use_sample_time = 1; const char *devtypename = (devtype == VideoDevice) ? "video" : "audio"; IReferenceClock *clock = pin->filter->clock; int64_t dummy; struct dshow_ctx *ctx; + HRESULT hr; dshowdebug("ff_dshow_meminputpin_Receive(%p)\n", this); @@ -314,22 +315,28 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) s = priv_data; ctx = s->priv_data; - IMediaSample_GetTime(sample, &sampletime, &dummy); + hr = IMediaSample_GetTime(sample, &sampletime, &dummy); IReferenceClock_GetTime(clock, &graphtime); if (devtype == VideoDevice && !ctx->use_video_device_timestamps) { /* PTS from video devices is unreliable. */ chosentime = graphtime; use_sample_time = 0; } else { - if (sampletime > 400000000000000000LL) { + if (hr == VFW_E_SAMPLE_TIME_NOT_SET || sampletime == 0) { + chosentime = graphtime; + use_sample_time = 0; + av_log(s, AV_LOG_DEBUG, + "frame with missing sample timestamp encountered, falling back to graph timestamp\n"); + } + else if (sampletime > 400000000000000000LL) { /* initial frames sometimes start < 0 (shown as a very large number here, like 437650244077016960 which FFmpeg doesn't like). TODO figure out math. For now just drop them. */ - av_log(NULL, AV_LOG_DEBUG, - "dshow dropping initial (or ending) frame with odd PTS too high %"PRId64"\n", sampletime); + av_log(s, AV_LOG_DEBUG, + "dropping initial (or ending) sample with odd PTS too high %"PRId64"\n", sampletime); return S_OK; - } - chosentime = sampletime; + } else + chosentime = sampletime; } // media sample time is relative to graph start time sampletime += pin->filter->start_time; @@ -340,7 +347,7 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) IMediaSample_GetPointer(sample, &buf); index = pin->filter->stream_index; - av_log(NULL, AV_LOG_VERBOSE, "dshow passing through packet of type %s size %8d " + av_log(s, AV_LOG_VERBOSE, "passing through packet of type %s size %8d " "timestamp %"PRId64" orig timestamp %"PRId64" graph timestamp %"PRId64" diff %"PRId64" %s\n", devtypename, buf_size, chosentime, sampletime, graphtime, graphtime - sampletime, ctx->device_name[devtype]); pin->filter->callback(priv_data, index, buf, buf_size, chosentime, devtype); -- 2.28.0.windows.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".