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 7E7E043D2A for ; Mon, 8 Aug 2022 15:11:22 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6554268B735; Mon, 8 Aug 2022 18:11:19 +0300 (EEST) Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 15D0D68B1F1 for ; Mon, 8 Aug 2022 18:11:13 +0300 (EEST) X-ENS-nef-client: 129.199.129.80 ( name = phare.normalesup.org ) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 278FBCSv025740 for ; Mon, 8 Aug 2022 17:11:12 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id 4B134E0082; Mon, 8 Aug 2022 17:11:12 +0200 (CEST) Date: Mon, 8 Aug 2022 17:11:12 +0200 From: Nicolas George To: FFmpeg development discussions and patches Message-ID: References: <20220808000124.12794-1-jamrial@gmail.com> MIME-Version: 1.0 In-Reply-To: <20220808000124.12794-1-jamrial@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Mon, 08 Aug 2022 17:11:12 +0200 (CEST) Subject: Re: [FFmpeg-devel] [PATCH] avfilter/framesync: add a new option to set how to sync streams based on secondary input 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 Content-Type: multipart/mixed; boundary="===============2643610234352083627==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============2643610234352083627== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="2kThsua7TQ29hf65" Content-Disposition: inline --2kThsua7TQ29hf65 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable James Almer (12022-08-07): > Include two values for it, a default one that sets/keeps the current beha= vior, > where the frame event generated by the primary input will have a timestamp > equal or higher than frames in secondary input, plus a new one where the > secondary input frame will be that with the absolute closest timestamp to= that > of the frame event one. >=20 > Addresses ticket #9689, where the new optional behavior produces better f= rame > syncronization. I do not find a better way of doing it. Thanks for the patch. >=20 > Signed-off-by: James Almer > --- > libavfilter/framesync.c | 19 +++++++++++++++++++ > libavfilter/framesync.h | 23 +++++++++++++++++++++++ > 2 files changed, 42 insertions(+) >=20 > diff --git a/libavfilter/framesync.c b/libavfilter/framesync.c > index 7510550d8e..bd784f6e0b 100644 > --- a/libavfilter/framesync.c > +++ b/libavfilter/framesync.c > @@ -42,6 +42,13 @@ static const AVOption framesync_options[] =3D { > { "pass", "Pass through the main input.", 0, AV_OPT_TYPE_CONST= , { .i64 =3D EOF_ACTION_PASS }, .flags =3D FLAGS, "eof_action" }, > { "shortest", "force termination when the shortest input terminates"= , OFFSET(opt_shortest), AV_OPT_TYPE_BOOL, { .i64 =3D 0 }, 0, 1, FLAGS }, > { "repeatlast", "extend last frame of secondary streams beyond EOF",= OFFSET(opt_repeatlast), AV_OPT_TYPE_BOOL, { .i64 =3D 1 }, 0, 1, FLAGS }, > + { "ts_sync_mode", "How strictly to sync streams based on secondary i= nput timestamps", > + OFFSET(opt_ts_sync_mode), AV_OPT_TYPE_INT, { .i64 =3D TS_DEFAULT= }, > + TS_DEFAULT, TS_NEAREST, .flags =3D FLAGS, "ts_sync_mode" }, > + { "default", "Frame from secondary input with the nearest lower = or equal timestamp to the primary input frame", > + 0, AV_OPT_TYPE_CONST, { .i64 =3D TS_DEFAULT }, .flags =3D FL= AGS, "ts_sync_mode" }, > + { "nearest", "Frame from secondary input with the absolute neare= st timestamp to the primary input frame", > + 0, AV_OPT_TYPE_CONST, { .i64 =3D TS_NEAREST }, .flags =3D FL= AGS, "ts_sync_mode" }, This should be a per-stream options, but our options parsing is not powerful enough for that. And since options are strings and my projects to have a good strings API are being blocked by somebody whose arguments can be summarized as =E2=80= =9CI never deal with strings, I do not know about our use of strings, therefore we do not need this API=E2=80=9D, we will not have a better optio= ns parsing system in the foreseeable future. But don't mind me, I'm just being bitter that this person does not extend to me the respect in abilities and trust in vision he enjoys. > { NULL } > }; > static const AVClass framesync_class =3D { > @@ -110,6 +117,14 @@ static void framesync_sync_level_update(FFFrameSync = *fs) > av_assert0(level <=3D fs->sync_level); > if (level < fs->sync_level) > av_log(fs, AV_LOG_VERBOSE, "Sync level %u\n", level); > + if (fs->opt_ts_sync_mode > TS_DEFAULT) { > + for (i =3D 0; i < fs->nb_in; i++) { > + if (fs->in[i].sync < level) > + fs->in[i].ts_mode =3D fs->opt_ts_sync_mode; > + else > + fs->in[i].ts_mode =3D TS_DEFAULT; > + } > + } > if (level) > fs->sync_level =3D level; > else > @@ -187,6 +202,10 @@ static int framesync_advance(FFFrameSync *fs) > } > for (i =3D 0; i < fs->nb_in; i++) { > if (fs->in[i].pts_next =3D=3D pts || > + (fs->in[i].ts_mode =3D=3D TS_NEAREST && > + fs->in[i].have_next && > + fs->in[i].pts_next !=3D INT64_MAX && fs->in[i].pts !=3D= AV_NOPTS_VALUE && > + FFABS(pts - fs->in[i].pts_next) < FFABS(pts - fs->in[i]= =2Epts)) || fs->in[i].pts_next - pts < pts - fs->in[i].pts No need for a FFABS since we know how they compare. > (fs->in[i].before =3D=3D EXT_INFINITY && > fs->in[i].state =3D=3D STATE_BOF)) { > av_frame_free(&fs->in[i].frame); > diff --git a/libavfilter/framesync.h b/libavfilter/framesync.h > index a246d2d1e5..233f50a0eb 100644 > --- a/libavfilter/framesync.h > +++ b/libavfilter/framesync.h > @@ -75,6 +75,27 @@ enum FFFrameSyncExtMode { > EXT_INFINITY, > }; > =20 > +/** > + * Timestamp syncronization mode > + * > + * Describe how the frames of a stream are syncronized based on timestamp > + * distance. > + */ > +enum FFFrameTSSyncMode { > + > + /** > + * Sync to frames from secondary input with the nearest, lower or eq= ual > + * timestamp to the frame event one. > + */ > + TS_DEFAULT, > + > + /** > + * Sync to frames from secondary input with the absolute nearest tim= estamp > + * to the frame event one. > + */ > + TS_NEAREST, > +}; > + > /** > * Input stream structure > */ > @@ -138,6 +159,7 @@ typedef struct FFFrameSyncIn { > */ > unsigned sync; > =20 > + enum FFFrameTSSyncMode ts_mode; > } FFFrameSyncIn; > =20 > /** > @@ -205,6 +227,7 @@ typedef struct FFFrameSync { > int opt_repeatlast; > int opt_shortest; > int opt_eof_action; > + int opt_ts_sync_mode; > =20 > } FFFrameSync; > =20 Ok except for the remark above. Regards, --=20 Nicolas George --2kThsua7TQ29hf65 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE6ooRQGBoNzw0KnwPcZVLI8pNxgwFAmLxJ4wACgkQcZVLI8pN xgzpKg/+N2j25Yv+3vki6ZBFIw7hGYwsLyumz2mFDIxvZ59cfhKZMqY+/fYq11ty oChSmHvlnuMXMBfmzFCPmfLUPLFMNzGCM13nEC4vSRaQSgFu1V2lbR6gyP27d54E sSU1h/jN6BjdyXnNZIhVQgYjxg3ZCp/+FNBUdjLrpK1k92D0AarFlOrww+u4wYnL FSN4yGhJ9SyNzN6yQkKTIeQBMpx+iqBvSeBtBMrSxNQSs8N0KKGXIkBn3H/B0gnQ U87Vuydp6SlZGWihEdWqoCSlQehog5Sn6eVQlu8LLLeX7POp+XeVsxT1hB7+ay/0 sqZ4eN9BUD1bC3Tp/XJHTAlHrLjMuEGWGAEHoftQjcAL7NgKGqCwvmPkyvysd2Co vqPPivB5iKV40Z9C5VPkle9CJwqxFdJboyNTpqCHPAeKXyZQT/8mcwSEuRO5AFf+ 5td/NvnbeKikXs2G4ckg09nusk02qEfiOwxjGzS6U41W2hFUploWFqGMrtMYYUOT ZTEBQZirm+0YwT4jL7iwEmIEFYwoWPjm3V/EbSTod8jSoKDpt0WjDIOFx1xboOoo uY+BaydnyoPxO8zpNpaxFj47745BPF1ybOB4M3x37V+qcWfy61GJcYY7jiLGBsX0 3SMH1+PeSWEmFNY+wDTK8AjELse9EWaEOqZFROKV6QGiPHCO53c= =24ak -----END PGP SIGNATURE----- --2kThsua7TQ29hf65-- --===============2643610234352083627== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". --===============2643610234352083627==--