Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 0/1] avfilter/framesync: fix forward EOF pts
@ 2024-05-28  9:11 Nicolas Gaullier
  2024-05-28  9:11 ` [FFmpeg-devel] [PATCH 1/1] " Nicolas Gaullier
  2024-06-03 10:00 ` [FFmpeg-devel] [PATCH 0/1] " Nicolas Gaullier
  0 siblings, 2 replies; 6+ messages in thread
From: Nicolas Gaullier @ 2024-05-28  9:11 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nicolas Gaullier

This a new ping but I post the patch again to get fate cleanly completed
on patchwork.
BTW, the initial design of framesync/EOF was in n3.4-dev-1799-g4e0e9ce2dc,
so one can say that time has past...

Thank you in advance for the review.
Nicolas

Nicolas Gaullier (1):
  avfilter/framesync: fix forward EOF pts

 libavfilter/framesync.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

-- 
2.30.2

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [FFmpeg-devel] [PATCH 1/1] avfilter/framesync: fix forward EOF pts
  2024-05-28  9:11 [FFmpeg-devel] [PATCH 0/1] avfilter/framesync: fix forward EOF pts Nicolas Gaullier
@ 2024-05-28  9:11 ` Nicolas Gaullier
  2024-06-03 10:00 ` [FFmpeg-devel] [PATCH 0/1] " Nicolas Gaullier
  1 sibling, 0 replies; 6+ messages in thread
From: Nicolas Gaullier @ 2024-05-28  9:11 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nicolas Gaullier

Note1: when the EOF pts is not accurate enough, the last frame
can be dropped by vf_fps with default rounding.

Note2: vf_scale use framesync since e82a3997cdd6c0894869b33ba42430ac3,
so this is a very commonplace scenario.

For example:
./ffprobe -f lavfi testsrc=d=1,scale,fps -of flat \
  -count_frames -show_entries stream=nb_read_frames

Before:
streams.stream.0.nb_read_frames="24"

After:
streams.stream.0.nb_read_frames="25"
---
 libavfilter/framesync.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/libavfilter/framesync.c b/libavfilter/framesync.c
index 535fbe9c7c..28a992ba6d 100644
--- a/libavfilter/framesync.c
+++ b/libavfilter/framesync.c
@@ -103,14 +103,14 @@ int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
     return 0;
 }
 
-static void framesync_eof(FFFrameSync *fs)
+static void framesync_eof(FFFrameSync *fs, int64_t pts)
 {
     fs->eof = 1;
     fs->frame_ready = 0;
-    ff_outlink_set_status(fs->parent->outputs[0], AVERROR_EOF, AV_NOPTS_VALUE);
+    ff_outlink_set_status(fs->parent->outputs[0], AVERROR_EOF, pts);
 }
 
-static void framesync_sync_level_update(FFFrameSync *fs)
+static void framesync_sync_level_update(FFFrameSync *fs, int64_t eof_pts)
 {
     unsigned i, level = 0;
 
@@ -131,7 +131,7 @@ static void framesync_sync_level_update(FFFrameSync *fs)
     if (level)
         fs->sync_level = level;
     else
-        framesync_eof(fs);
+        framesync_eof(fs, eof_pts);
 }
 
 int ff_framesync_configure(FFFrameSync *fs)
@@ -179,7 +179,7 @@ int ff_framesync_configure(FFFrameSync *fs)
     for (i = 0; i < fs->nb_in; i++)
         fs->in[i].pts = fs->in[i].pts_next = AV_NOPTS_VALUE;
     fs->sync_level = UINT_MAX;
-    framesync_sync_level_update(fs);
+    framesync_sync_level_update(fs, AV_NOPTS_VALUE);
 
     return 0;
 }
@@ -200,7 +200,7 @@ static int framesync_advance(FFFrameSync *fs)
             if (fs->in[i].have_next && fs->in[i].pts_next < pts)
                 pts = fs->in[i].pts_next;
         if (pts == INT64_MAX) {
-            framesync_eof(fs);
+            framesync_eof(fs, AV_NOPTS_VALUE);
             break;
         }
         for (i = 0; i < fs->nb_in; i++) {
@@ -222,7 +222,7 @@ static int framesync_advance(FFFrameSync *fs)
                     fs->frame_ready = 1;
                 if (fs->in[i].state == STATE_EOF &&
                     fs->in[i].after == EXT_STOP)
-                    framesync_eof(fs);
+                    framesync_eof(fs, AV_NOPTS_VALUE);
             }
         }
         if (fs->frame_ready)
@@ -255,15 +255,14 @@ static void framesync_inject_frame(FFFrameSync *fs, unsigned in, AVFrame *frame)
     fs->in[in].have_next  = 1;
 }
 
-static void framesync_inject_status(FFFrameSync *fs, unsigned in, int status, int64_t pts)
+static void framesync_inject_status(FFFrameSync *fs, unsigned in, int status, int64_t eof_pts)
 {
     av_assert0(!fs->in[in].have_next);
-    pts = fs->in[in].state != STATE_RUN || fs->in[in].after == EXT_INFINITY
-        ? INT64_MAX : framesync_pts_extrapolate(fs, in, fs->in[in].pts);
     fs->in[in].sync = 0;
-    framesync_sync_level_update(fs);
+    framesync_sync_level_update(fs, status == AVERROR_EOF ? eof_pts : AV_NOPTS_VALUE);
     fs->in[in].frame_next = NULL;
-    fs->in[in].pts_next   = pts;
+    fs->in[in].pts_next   = fs->in[in].state != STATE_RUN || fs->in[in].after == EXT_INFINITY
+                            ? INT64_MAX : framesync_pts_extrapolate(fs, in, fs->in[in].pts);
     fs->in[in].have_next  = 1;
 }
 
-- 
2.30.2

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [FFmpeg-devel] [PATCH 0/1] avfilter/framesync: fix forward EOF pts
  2024-05-28  9:11 [FFmpeg-devel] [PATCH 0/1] avfilter/framesync: fix forward EOF pts Nicolas Gaullier
  2024-05-28  9:11 ` [FFmpeg-devel] [PATCH 1/1] " Nicolas Gaullier
@ 2024-06-03 10:00 ` Nicolas Gaullier
  2024-06-14 11:26   ` Nicolas Gaullier
  1 sibling, 1 reply; 6+ messages in thread
From: Nicolas Gaullier @ 2024-06-03 10:00 UTC (permalink / raw)
  To: ffmpeg-devel

>Envoyé : mardi 28 mai 2024 11:11
>
>This a new ping but I post the patch again to get fate cleanly completed on patchwork.
>BTW, the initial design of framesync/EOF was in n3.4-dev-1799-g4e0e9ce2dc, so one can say that time has past...
>
>Thank you in advance for the review.
>Nicolas

Another ping.
Patch still applies
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=11939

Thank you
Nicolas
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [FFmpeg-devel] [PATCH 0/1] avfilter/framesync: fix forward EOF pts
  2024-06-03 10:00 ` [FFmpeg-devel] [PATCH 0/1] " Nicolas Gaullier
@ 2024-06-14 11:26   ` Nicolas Gaullier
  2024-07-08 12:36     ` Nicolas Gaullier
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Gaullier @ 2024-06-14 11:26 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

>Envoyé : lundi 3 juin 2024 12:00
>>Envoyé : mardi 28 mai 2024 11:11
>>
>>This a new ping but I post the patch again to get fate cleanly completed on patchwork.
>>BTW, the initial design of framesync/EOF was in n3.4-dev-1799-g4e0e9ce2dc, so one can say that time has past...
>>
>>Thank you in advance for the review.
>>Nicolas
>
>Another ping.
>Patch still applies
>https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=11939

Still applies to current master.
Anyone to review ?
To summarize, and for remembering, the initial commit was 4e0e9ce2dc, 7 years ago, and inserted this:
ff_outlink_set_status(fs->parent->outputs[0], AVERROR_EOF, AV_NOPTS_VALUE)
The target of this patch is to make it a:
ff_outlink_set_status(fs->parent->outputs[0], AVERROR_EOF, eof_pts)

My use case is that I frequently chain the scale filter with the fps filter,
and since the scale filter use framesync since e82a3997cdd6c0 (3rd of May this year),
this is becoming a full issue (yet I have not find any corresponding trac entry so far).

Thanks
Nicolas
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [FFmpeg-devel] [PATCH 0/1] avfilter/framesync: fix forward EOF pts
  2024-06-14 11:26   ` Nicolas Gaullier
@ 2024-07-08 12:36     ` Nicolas Gaullier
  2024-07-17 10:09       ` Anton Khirnov
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Gaullier @ 2024-07-08 12:36 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

>Envoyé : vendredi 14 juin 2024 13:27
>>Envoyé : lundi 3 juin 2024 12:00
>>>Envoyé : mardi 28 mai 2024 11:11
>>>
>>>This a new ping but I post the patch again to get fate cleanly completed on patchwork.
>>>
>>https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=11939
>
>To summarize, and for remembering, the initial commit was 4e0e9ce2dc, 7 years ago, and inserted this:
>ff_outlink_set_status(fs->parent->outputs[0], AVERROR_EOF, AV_NOPTS_VALUE)
>The target of this patch is to make it a:
>ff_outlink_set_status(fs->parent->outputs[0], AVERROR_EOF, eof_pts)
>
>My use case is that I frequently chain the scale filter with the fps filter, and since the scale filter uses framesync since e82a3997cdd6c0 (3rd of May this year), this is becoming a "full" issue

Pinging again, the patch still applies...

Thank you
Nicolas
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [FFmpeg-devel] [PATCH 0/1] avfilter/framesync: fix forward EOF pts
  2024-07-08 12:36     ` Nicolas Gaullier
@ 2024-07-17 10:09       ` Anton Khirnov
  0 siblings, 0 replies; 6+ messages in thread
From: Anton Khirnov @ 2024-07-17 10:09 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Quoting Nicolas Gaullier (2024-07-08 14:36:38)
> >Envoyé : vendredi 14 juin 2024 13:27
> >>Envoyé : lundi 3 juin 2024 12:00
> >>>Envoyé : mardi 28 mai 2024 11:11
> >>>
> >>>This a new ping but I post the patch again to get fate cleanly completed on patchwork.
> >>>
> >>https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=11939
> >
> >To summarize, and for remembering, the initial commit was 4e0e9ce2dc, 7 years ago, and inserted this:
> >ff_outlink_set_status(fs->parent->outputs[0], AVERROR_EOF, AV_NOPTS_VALUE)
> >The target of this patch is to make it a:
> >ff_outlink_set_status(fs->parent->outputs[0], AVERROR_EOF, eof_pts)
> >
> >My use case is that I frequently chain the scale filter with the fps filter, and since the scale filter uses framesync since e82a3997cdd6c0 (3rd of May this year), this is becoming a "full" issue
> 
> Pinging again, the patch still applies...

Could you please add a test demonstrating the issue?

-- 
Anton Khirnov
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-07-17 10:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-28  9:11 [FFmpeg-devel] [PATCH 0/1] avfilter/framesync: fix forward EOF pts Nicolas Gaullier
2024-05-28  9:11 ` [FFmpeg-devel] [PATCH 1/1] " Nicolas Gaullier
2024-06-03 10:00 ` [FFmpeg-devel] [PATCH 0/1] " Nicolas Gaullier
2024-06-14 11:26   ` Nicolas Gaullier
2024-07-08 12:36     ` Nicolas Gaullier
2024-07-17 10:09       ` Anton Khirnov

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git