From patchwork Sat Jun 25 08:29:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 36422 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:8b27:b0:88:1bbf:7fd2 with SMTP id l39csp793975pzh; Sat, 25 Jun 2022 01:30:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vXRFbqb2QOSG0FdZHJcFhTC9+qhD7FEt03APMr7IUQnUexsW8TGoiyCYPwwQ0EaLyYDIfz X-Received: by 2002:a05:6402:4306:b0:435:a1c9:4272 with SMTP id m6-20020a056402430600b00435a1c94272mr3741015edc.205.1656145819305; Sat, 25 Jun 2022 01:30:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656145819; cv=none; d=google.com; s=arc-20160816; b=k66sBBL7012F6jJ1aNl3sTpzWUW6RhDKeQnZjAze+NAIcTzxKZETCpsLsqbSQil/8W nYZvpJTEyr4y5vgbIz7n7TtFq9BgwhqV6A3lqEnnYIq35AMF6I6/kJelHC/q5kAB4WTt LViVPyZat+Z35FTqrsg1lFgUm1AF79+lVIIUwpZJyg7o0pJ9yCBWXV9r8lwEzWyo/2bf N6Kq/tFxZ4IMvqyUKnj2cSUX3+vuHvxyTwf38/C/g/wi24vlCUnR8EGfkyPZLD0nsKpF xKUrq3gKMcBLihO3TX88YMO4njNfevZL8AH7ZIWmZN76bsfGpGLwZHX3O+wrVkfmPrEx Kiag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=LLAFTG1xymGnKe7B5+shOoFHSntaFgn8JUwSmJyYYr4=; b=TVLOvAopZnUfcxX8tHIJqrv8BJdK7K4FjXsBFNxIgob7BpxaZyvmWfvRvBxlqqMdlk 2JqZ3L2VLXL0QXqeEEG9rhGAEqItZUI/HwHXRf8Fg8Uz16uNSgAH4AidfHT/4bLtpYTQ pCshVN7qIrdEGODxU77APhelPyySSEHQtVeNBNdehJCt7pD8YZitsf4M4amu4h0+E9oi 75RxjqdvOfEtJ6JpxJlo6sVZehL8a6WLiSuWSDQuGzf3ny8cJreqPpyvPMU7OGI+vNpA qhbpidGcb+i2a0PJP5gcDm6PzssbHbgGT4U+qmdimedAx1QNWNNu2atahMQf4bF6EApN cpCg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u25-20020a056402065900b004356afc7003si5375798edx.169.2022.06.25.01.30.18; Sat, 25 Jun 2022 01:30:19 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 19CB368B7E8; Sat, 25 Jun 2022 11:30:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1B91368B63B for ; Sat, 25 Jun 2022 11:30:09 +0300 (EEST) Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4LVRxq5qKkz9sb6 for ; Sat, 25 Jun 2022 10:30:07 +0200 (CEST) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Sat, 25 Jun 2022 13:59:50 +0530 Message-Id: <20220625082951.11897-1-ffmpeg@gyani.pro> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/2] avformat: add AVFormatContext.first_pkt_wallclock 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Tp3fKCSU3vH8 Stores wallclock time for the first packet received. Used for crude sync offset among inputs. --- doc/APIchanges | 3 +++ libavformat/avformat.h | 10 ++++++++++ libavformat/demux.c | 3 +++ libavformat/options.c | 1 + libavformat/version.h | 2 +- 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 20b944933a..94c53d283f 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-06-xx - xxxxxxxxxx - lavf 59.26.100 - avformat.h + Add and set AVFormatContext.first_pkt_wallclock field. + 2022-06-12 - xxxxxxxxxx - lavf 59.25.100 - avio.h Add avio_vprintf(), similar to avio_printf() but allow to use it from within a function taking a variable argument list as input. diff --git a/libavformat/avformat.h b/libavformat/avformat.h index f12fa7d904..a45777ab39 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1808,6 +1808,16 @@ typedef struct AVFormatContext { */ int max_probe_packets; + /** + * Wallclock start time of the stream in real world time, in microseconds + * since the Unix epoch (00:00 1st January 1970). That is, the first packet + * was received at this real world time. + * - demuxing: Set by libavformat. Users may want to use start_time_realtime + * if set. + * - muxing: unused. + */ + int64_t first_pkt_wallclock; + /** * A callback for closing the streams opened with AVFormatContext.io_open(). * diff --git a/libavformat/demux.c b/libavformat/demux.c index e121253dfd..7e0540debf 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -628,6 +628,9 @@ FF_ENABLE_DEPRECATION_WARNINGS force_codec_ids(s, st); + if (s->first_pkt_wallclock == AV_NOPTS_VALUE) + s->first_pkt_wallclock = av_gettime(); + /* TODO: audio: time filter; video: frame reordering (pts != dts) */ if (s->use_wallclock_as_timestamps) pkt->dts = pkt->pts = av_rescale_q(av_gettime(), AV_TIME_BASE_Q, st->time_base); diff --git a/libavformat/options.c b/libavformat/options.c index 0079a06d9a..77d4dfd1d0 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -184,6 +184,7 @@ AVFormatContext *avformat_alloc_context(void) return NULL; } + s->first_pkt_wallclock = AV_NOPTS_VALUE; si->shortest_end = AV_NOPTS_VALUE; return s; diff --git a/libavformat/version.h b/libavformat/version.h index 966ebb7ed3..0708d619c0 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,7 +31,7 @@ #include "version_major.h" -#define LIBAVFORMAT_VERSION_MINOR 25 +#define LIBAVFORMAT_VERSION_MINOR 26 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \