From patchwork Wed Jun 2 13:22:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Diederick C. Niehorster" X-Patchwork-Id: 28058 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp543196iof; Wed, 2 Jun 2021 06:22:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzozLyKC5rBJlBWZMHsrworH2b/fYxb9Vzn0rCbRXsgjjgpwr4UjOUn3D7kjYl8/Qt7Te2S X-Received: by 2002:a17:906:fc4:: with SMTP id c4mr35943288ejk.111.1622640178332; Wed, 02 Jun 2021 06:22:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622640178; cv=none; d=google.com; s=arc-20160816; b=fny5zixtTLBRJxvU5sJ3COAwbYot4YtQiLcLNqf0jD/uAioI0xXOqQOMabPciD6RMT wFTQdnfE1nZPHwt8BVf6i+DvzK5XRc94XUDnBiMiFOSWh8h1CnekWChke5yd7XbyqfW8 arP+xkVew0H8nFMdIhmc2of1NYPoIccCCIaEiL+zOnV/h+W2WoNXOVcS6dkY73DbWdJO r9DZGQ7y4jnQvSNQDHUcLKVISknOclG0cB9FOM8qrx0NtZX81OKS9Sr8JYDwbMnUwD89 g/8xZ5rSBo+JiP0hLBs4yCkQg3lw23eDPysH9BiH8oFsWDqA7ImDap8awV/rmH3AnjM9 y8Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=n+1h5Pj8Yznd8PDugzPaxTFxogtxzSFWyq3m0p9d+Dc=; b=tF3nEIT4lmXwFmsYM6QhtUCpA7e1IDGikvlxMkkOo9K8rrJ04iYgK6G4DB+z5+mjtz TQ+zX4822fBJftXGF5JSNPHOBk+SL9nUMz6ZOXtg+7armX8oY/0C+OH2iWGn4BNDiO/9 FX3mXMz1DjWWUlxoMYBrlF/8Wq75x+NZtPoMrADynj2nnbwQQDVBsrMdV/jPxEvdZZlL Ay0nXFrZJUucUuRR+hDON3tgGgsfwQw4as5oQEnotHoG3f36HqnONczghZyuaI4XYvyj jbVahpvD2nEpRF/h9AY7/TbdDHccO5hCP3gRedCtkMoZS9A5zansVRD8mVeK5lNj4g3Y DzIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=F8p7WV9C; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a6si15079485ejy.213.2021.06.02.06.22.57; Wed, 02 Jun 2021 06:22:58 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=F8p7WV9C; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 53ABD68A0BB; Wed, 2 Jun 2021 16:22:47 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 27BBA68A083 for ; Wed, 2 Jun 2021 16:22:45 +0300 (EEST) Received: by mail-lj1-f178.google.com with SMTP id c11so2568265ljd.6 for ; Wed, 02 Jun 2021 06:22: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=Y19qOMjGGKr5xGk6cHPSNfbfrDqLi73/t+0ht7DgUVY=; b=F8p7WV9CJUcKA0DkbKbKM5g6y2IB6yZOms10Db7VVIvzyeE4O9TgBzVqwcjBEC/MPx obnpBdlHpcg4iaqKNagErDO70oqQ5r5luzpKLwsJhWMEBXKOxmzkKTinVchK+e9g6iXK masKSa68u+9af5mi94cyPcE8JExsDcapS12PIHsdN8rv5Sq2u2gIHeR+98jnTqalh7dZ TBz8UewPxn2o8S20PjDEXK06v5rymHZoPIq+YpG5ooqPj81zNiaL/RXBfytSps2Qw+mo ZhXAi49uO6XN32tZphLFRPYkq3AKY56rhvKs9rpAE4mB2DxFmZKLmIZFuRmSLytIAqH9 TNTg== 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=Y19qOMjGGKr5xGk6cHPSNfbfrDqLi73/t+0ht7DgUVY=; b=CuXzUZVA+lX7L8dR+CrVSHXxqRrV59pextseyEGjAHVKbK1sBfQlzOKNuBhNtLCZUl IvZfH4mfgbpVYP9ihKgGKlxTU8dysuHJFIBbswaiK2LV/Ky71Aivu38CLLzvah3n0Dio SjznCjaWLlO7bsnuv+nnXmR9AxssB25qvzoWp0Spye5ydWGGMPMHY9tFL94vHCgbr8fz BZph9g3+VAdxiYgJPz3il7uG/XRmhwqeuzXzKUaNcuNm5+nAT3ZKyxtb2W37pu/ibSSV qjj7ZoL/lFsfmQclD+NbSGSo1IUJgoxjYAzf+sKWLGcKiCCMgEyqBUokNSDLFSCwOTvL bXaQ== X-Gm-Message-State: AOAM531dvn7e59u2WAKIfsj3p7UWoZgqzKd/pviBlKz11nLA9yz3hFO7 8zB+E6uqfg7e8H1qgarNSbBRi8fTP2b9bg== X-Received: by 2002:a05:651c:1105:: with SMTP id d5mr24930991ljo.431.1622640164902; Wed, 02 Jun 2021 06:22:44 -0700 (PDT) Received: from localhost.localdomain (deedock.humlab.lu.se. [130.235.135.183]) by smtp.gmail.com with ESMTPSA id y26sm1315041lfj.298.2021.06.02.06.22.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 06:22:44 -0700 (PDT) From: Diederick Niehorster To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Jun 2021 15:22:28 +0200 Message-Id: <20210602132230.2380-2-dcnieho@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20210602132230.2380-1-dcnieho@gmail.com> References: <20210602132230.2380-1-dcnieho@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avdevice/dshow: implement option to use device video timestamps 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: djpiHoFGHhn/ The dshow plugin ignores timestamps for video frames provided by the DirectShow device, instead using wallclock time, apparently because the implementer of this code had a device that provided unreliable timestamps. Me (and others) would like to use the device's timestamps. The new use_video_device_timestamps option for dshow device enables them to do so. Since the majority of video devices out there probably provide fine timestamps, this patch sets the default to using the device timestamps, which means best fidelity timestamps are used by default. Using the new option, the user can switch this off and revert to the old behavior, so a fall back remains available in case the device provides broken timestamps. Solves trac #8620. Signed-off-by: Diederick Niehorster --- libavdevice/dshow.c | 1 + libavdevice/dshow_capture.h | 1 + libavdevice/dshow_pin.c | 13 +++++++------ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 8d0a6fcc09..2e9f9ddf3f 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -1317,6 +1317,7 @@ static const AVOption options[] = { { "audio_device_save", "save audio capture filter device (and properties) to file", OFFSET(audio_filter_save_file), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, { "video_device_load", "load video capture filter device (and properties) from file", OFFSET(video_filter_load_file), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, { "video_device_save", "save video capture filter device (and properties) to file", OFFSET(video_filter_save_file), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "use_video_device_timestamps", "use device instead of wallclock timestamps for video frames", OFFSET(use_video_device_timestamps), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DEC }, { NULL }, }; diff --git a/libavdevice/dshow_capture.h b/libavdevice/dshow_capture.h index 06ded2ba96..5a2691518c 100644 --- a/libavdevice/dshow_capture.h +++ b/libavdevice/dshow_capture.h @@ -312,6 +312,7 @@ struct dshow_ctx { char *audio_filter_save_file; char *video_filter_load_file; char *video_filter_save_file; + int use_video_device_timestamps; IBaseFilter *device_filter[2]; IPin *device_pin[2]; diff --git a/libavdevice/dshow_pin.c b/libavdevice/dshow_pin.c index 3dae405e65..ee0d4a1b42 100644 --- a/libavdevice/dshow_pin.c +++ b/libavdevice/dshow_pin.c @@ -309,12 +309,16 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) if (!sample) return E_POINTER; + priv_data = pin->filter->priv_data; + s = priv_data; + ctx = s->priv_data; + IMediaSample_GetTime(sample, &orig_curtime, &dummy); orig_curtime += pin->filter->start_time; IReferenceClock_GetTime(clock, &graphtime); - if (devtype == VideoDevice) { - /* PTS from video devices is unreliable. */ - IReferenceClock_GetTime(clock, &curtime); + if (devtype == VideoDevice && !ctx->use_video_device_timestamps) { + /* PTS from video devices is unreliable. */ + IReferenceClock_GetTime(clock, &curtime); } else { IMediaSample_GetTime(sample, &curtime, &dummy); if(curtime > 400000000000000000LL) { @@ -330,9 +334,6 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) buf_size = IMediaSample_GetActualDataLength(sample); IMediaSample_GetPointer(sample, &buf); - priv_data = pin->filter->priv_data; - s = priv_data; - ctx = s->priv_data; index = pin->filter->stream_index; av_log(NULL, AV_LOG_VERBOSE, "dshow passing through packet of type %s size %8d " From patchwork Wed Jun 2 13:22:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Diederick C. Niehorster" X-Patchwork-Id: 28060 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp543311iof; Wed, 2 Jun 2021 06:23:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaKXxjHd1xyJTJd+Id3t+0P/62zVJJGGO3S7GAm1K0+DXMC4k5MfqaNJ/Z8A8w/RT5wut1 X-Received: by 2002:a17:906:5488:: with SMTP id r8mr34720656ejo.374.1622640186645; Wed, 02 Jun 2021 06:23:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622640186; cv=none; d=google.com; s=arc-20160816; b=kE/LCZLXDyBj1+67OvLYyCi5rxJCo9J4wh05rNyb3niTVnW6ugo9qIFvL9X4b2hUqQ 1VLOpBZ0ZK/dmAAOp5ym/IiNDuEuSequq/HWOQXnT0xiIgDYJJwvKG/gTQuHFhLBj3X/ whLYrzjJDqNJrpIKpgwbQ/xx3ogdAENVW9h3tcOD674JiRvVmfy04ASaoaCkpanUwf0p 6aDekHHCvgBEkwa+uKVNi3ndjBARpNmRKVe5zVavrSopRnaxiYQQkzfd7IYkWNl0SKQr kUkZxVXj4EBCLTfn8e5nZDhsAah49eoe1l7AY2qoqXGIbUi4MvHqwzuG+lwGXvhZC/yc rwjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=G/nlSHbdH0oVS9S1cpJLnVKPHwD9EwPLvftEdGKhZYI=; b=a7G3QFLaEEg2nU98v7/NOzz0sdSEz1uZoK8aNlD7CwK7Wer306fBn2WjpFyk9NhunG /4qsrjdZqeCbvK47Es0v6L21HOSJUMd46O6L6/CvBMpLKUZkQeSRiXYyQzAXC/AAyH8L PJJmTM9suFxTGt9bpHxIYbboJykcviwNaD3ZC7ccOmsrl4Yc9Uybuy44TZrTIVl0Pa6z H8XlaQl2fycPzHfS39JvoTSFlsJpUkZj15Ar5cfRaE1gK/1HDPryVI0un1sQWAiSiLVF SAgFuayqTuT/jn/AI4xrGlnmKI/lYIxxcTdWCAP05ZEfc/OKOcxb106xfIXMgq9Uo5pB 8ltg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=YUDC8Hiv; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id nc14si20887633ejc.387.2021.06.02.06.23.06; Wed, 02 Jun 2021 06:23:06 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=YUDC8Hiv; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4647E68A0D3; Wed, 2 Jun 2021 16:22:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D1E5D68A0AB for ; Wed, 2 Jun 2021 16:22:46 +0300 (EEST) Received: by mail-lj1-f170.google.com with SMTP id a4so2573833ljd.5 for ; Wed, 02 Jun 2021 06:22:46 -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=MXNmGSJ4i+FsWxNCF+F+wtXABVMvUOStpEsVdr0BTY8=; b=YUDC8HivODIvr75W7XEPALVQIcvsiu5ohgZze2X2/1HfYNHcwzVrpwPQidvI2ztkU9 VK3tQH2YlEHRa+0xBd9qsTYB2SfIAD2+mBjGGfPz0YXAYyTLLbiu1t4qr5PIJycqffqH 6at/f8Q2xrvSk1yiF5RnVD8Oyx9zEKSZZUkXDaxHhq46w09cpIfz+r6UFaGgiv0eaz5Z ta+adLNqZWCTcQBiX+nn9LfCvWMmnJ935wP2Mvy+7y9FTFXhBw+YwC9yPJhG+jAaJcsv q5YarMB3XITjay32zH666l8TDPjH/vbssxmoKY7HYaDXls8o7ZiI80rfj7dsTtU4wstG 63Dw== 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=MXNmGSJ4i+FsWxNCF+F+wtXABVMvUOStpEsVdr0BTY8=; b=ZWBxCSSURjJWgiVrYBup7tqieNLs+2TI3zwPJIrZ8Hy2j4BGAjH8+bbcGRUNz6hkWB 6nUJQMEBoKQNO+ouOy+QV/ZbL8x89d4fmIBVcjs+0IKu3hvzVNlfRoexNHA5rGHiZaBd mk6h72bi5wBEp8GJUCVLbo5WWLyD730PZ7aLI8tKKdpAcl9mH3QGwRLyFM/m7IxnKqL4 jGe0lyTpfThv1fzdawxW/U1Nu4dHu0uK3xlQXqOBEd6sd/iV1oXqfIf87t5XzkPAnMT5 dnxTyjxk26v9D1t2P8FKM4cQJ3CFZjmblWfl4xtH9lorRbB0Rjtb9ZSroU2iFTYdKCBC LnKQ== X-Gm-Message-State: AOAM530v2k+3hjqRUMg/rFFwLnmApUO8Fab1cN37j0tSGYek52Kay1lH 6/KcEfrjiPYw3BcowLgMaf2yhcr+gAmjLg== X-Received: by 2002:a2e:a554:: with SMTP id e20mr24669477ljn.23.1622640165676; Wed, 02 Jun 2021 06:22:45 -0700 (PDT) Received: from localhost.localdomain (deedock.humlab.lu.se. [130.235.135.183]) by smtp.gmail.com with ESMTPSA id y26sm1315041lfj.298.2021.06.02.06.22.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 06:22:45 -0700 (PDT) From: Diederick Niehorster To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Jun 2021 15:22:29 +0200 Message-Id: <20210602132230.2380-3-dcnieho@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20210602132230.2380-1-dcnieho@gmail.com> References: <20210602132230.2380-1-dcnieho@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avdevice/dshow: query graph time only once 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: NL2WpmoY8GNL No need to query twice, use value we've already unconditionally got. Signed-off-by: Diederick Niehorster --- libavdevice/dshow_pin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavdevice/dshow_pin.c b/libavdevice/dshow_pin.c index ee0d4a1b42..8408af26da 100644 --- a/libavdevice/dshow_pin.c +++ b/libavdevice/dshow_pin.c @@ -317,8 +317,8 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) orig_curtime += pin->filter->start_time; IReferenceClock_GetTime(clock, &graphtime); if (devtype == VideoDevice && !ctx->use_video_device_timestamps) { - /* PTS from video devices is unreliable. */ - IReferenceClock_GetTime(clock, &curtime); + /* PTS from video devices is unreliable. */ + curtime = graphtime; } else { IMediaSample_GetTime(sample, &curtime, &dummy); if(curtime > 400000000000000000LL) { From patchwork Wed Jun 2 13:22:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Diederick C. Niehorster" X-Patchwork-Id: 28057 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp543438iof; Wed, 2 Jun 2021 06:23:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWA5TOi1cqqGTPuGwJsm0L8psR/plM49vH+cI+3odGXxH0j1tx0lyYVXJLJBPJKVN/Lkt7 X-Received: by 2002:a05:6402:b11:: with SMTP id bm17mr21537943edb.109.1622640196104; Wed, 02 Jun 2021 06:23:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622640196; cv=none; d=google.com; s=arc-20160816; b=bDOSMuqajcRDZkXw07S27tdHw3aFOT+rLb9z6xaNa1ZuFgKNRwJjzYyj7yubO8hF7h 7F2h1orhRUBelGv4fy/xE8cUy2jLchStYXPlCJ4uWdCGu41MUUfZHYp/8p2yW/IgJlXy peUoIw5GK4EWpFxSmgbmq3m8P8D9LNJUi9ZbEcOB8MFjVrySaQzleizxwlVs6OBXRE+u r48iCSEGuufI7Bm7Gp4glq5ngbBvx1yY0stScJVA4hZiLQD4qO8e6vSuVaaZhfeofhpG RNuusI3gnFIncM4sEImNPb7bPw0twYDQ/zgw+1VTuLnHM5dXcWPVJzhjFk150hgf3vLU wrKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=sy5MRnRQhAgtlpPA0pEH/tH6lnYdKvDtHSeCWc3H4hA=; b=0XYXPomjLnDEkThW/hdYiZNYaTq6FSuM3nds7iKgUIyKVNcfabUzPXmbCtggIoZUa9 rmd7QHSiYOMAcfbQKTG8KpdmV+gM8WtQdmo8fpz78rTIVrSltKHoWCbXgEd3sfzmfFOt dA7eDwQqZ66VlVlL/r0o4B5KFrj8k6m5GY8HupXhMV+Jtp1/1wlnSQ+n/6shVEPXC9l0 gX4XLHIHGA1lsJLV0TYFEyu6AvA20ckb/MULLDbqBhkyqExgk35Yp01wUszf9tlMby80 fum0sCBDdAfg8WlgBLUMs3pa28asjJCbygJ0bt5aBtKxPCDW9WJCSmqAGTWGOG8Mp84w IirQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=OtlgIoSd; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l14si1694146edb.409.2021.06.02.06.23.15; Wed, 02 Jun 2021 06:23:16 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=OtlgIoSd; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1E4EE68A0F0; Wed, 2 Jun 2021 16:22:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5A24D68A0BF for ; Wed, 2 Jun 2021 16:22:47 +0300 (EEST) Received: by mail-lj1-f178.google.com with SMTP id 131so2583539ljj.3 for ; Wed, 02 Jun 2021 06:22:47 -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=366f5a59XEyjp0MRolXjKiLw3iE7UfOYpM3EFupiMbY=; b=OtlgIoSdxuh8rTeGZQ3o77CJAbmv3PqFwQ8aNeJzrp9lRT4TI6iGe4M/ahNsoJl/Ww x5FlT5Uz3ivoWrwF4U+f6xXFVDs63A16r2VH7Y9b7Olocla11atxa3Erj2EOX5aEt64x PUniylQq95FiZacQulBVRl95+jUzi0BwBHbJz/N3xjvUL5ZRkiQjLhUn2tXiolMqYG9B YMBNTYGCGqpeJLDoVef9oL8GzRXpVe08EfP+hBPCJh7TtVXTdvMzlBvG2w2EwaBrVh8u he28t31txvrNz8ssoGs0Vn/azapCpS/thGVV7tg/4Q5WqmhWF024gjEKC7Z26L4RxjRV 1/JQ== 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=366f5a59XEyjp0MRolXjKiLw3iE7UfOYpM3EFupiMbY=; b=FTV4xRL6jTDyMg0oTZoMHdMgQEmn/FP9YL1p9jNm8JqbZz/EWyzkbAA/GUkT0O5pFD kbNrf3/nebAwmTnNNwJX0alknoxbscOdQrKrGhlrFrXA6i64yV0YGh/m0HVYg6nNAgJU ttkrg57N3sf7s2UYl/xHEFFPfvQmvct9kgEApQhnZqv0sQKrxOHYX5QyGBaYKUBkVUit mEOdVNfSIiHYZSAF7bYlMaQx92Vz8wIswiSf4feUeUgV4RZFvX3M58XIyJkqWFUIOFcM dpgB7zdGyDFJ6OZpmf3UQqdLs9qNwSYPrQcnrg0+OnhnjXYilg1TtQ7xixOrfGWFBN6e qb4w== X-Gm-Message-State: AOAM5302R9jld85dJBBxa/xTMV5m32JbMY1qe2djyXV+hOB+HhEjcrvW ibAmIx/xHGlPWE7gmRNCwuJ9zQaO7+99xw== X-Received: by 2002:a2e:7606:: with SMTP id r6mr25110016ljc.432.1622640166406; Wed, 02 Jun 2021 06:22:46 -0700 (PDT) Received: from localhost.localdomain (deedock.humlab.lu.se. [130.235.135.183]) by smtp.gmail.com with ESMTPSA id y26sm1315041lfj.298.2021.06.02.06.22.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 06:22:45 -0700 (PDT) From: Diederick Niehorster To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Jun 2021 15:22:30 +0200 Message-Id: <20210602132230.2380-4-dcnieho@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20210602132230.2380-1-dcnieho@gmail.com> References: <20210602132230.2380-1-dcnieho@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: x5oZkY2/6ZWW 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 better debug message in case sample dropped: could now be audio or video frame Signed-off-by: Diederick Niehorster --- libavdevice/dshow_pin.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libavdevice/dshow_pin.c b/libavdevice/dshow_pin.c index 8408af26da..160f1e1324 100644 --- a/libavdevice/dshow_pin.c +++ b/libavdevice/dshow_pin.c @@ -295,8 +295,8 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) uint8_t *buf; int buf_size; /* todo should be a long? */ int index; - int64_t curtime; - int64_t orig_curtime; + int64_t curtime = 0; + int64_t orig_curtime = 0; int64_t graphtime; const char *devtypename = (devtype == VideoDevice) ? "video" : "audio"; IReferenceClock *clock = pin->filter->clock; @@ -320,13 +320,15 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) /* PTS from video devices is unreliable. */ curtime = graphtime; } else { - IMediaSample_GetTime(sample, &curtime, &dummy); - if(curtime > 400000000000000000LL) { + HRESULT hr = IMediaSample_GetTime(sample, &curtime, &dummy); + if (hr==VFW_E_SAMPLE_TIME_NOT_SET || curtime==0) { + curtime = graphtime; + } else if (curtime > 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) audio frame with odd PTS too high %"PRId64"\n", curtime); + "dshow dropping initial (or ending) audio with odd PTS too high %"PRId64"\n", curtime); return S_OK; } curtime += pin->filter->start_time;