diff mbox

[FFmpeg-devel,4/4] ffmpeg: send EOF pts to filters.

Message ID 20170406084451.27892-4-george@nsup.org
State Accepted
Commit 8043d8eb3bf5e93709212850feb3441b9ec41b25
Headers show

Commit Message

Nicolas George April 6, 2017, 8:44 a.m. UTC
Signed-off-by: Nicolas George <george@nsup.org>
---
 ffmpeg.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)


With this change, filters have a timestamp when EOF is reached, available in
link->current_pts. For example, vf_fps could make use of it to fix the
duration of the last frame; the logic in vf_fps seems unnecessarily
complicated, I have not yet implemented this, but a quick fix could be
possible.

Comments

Michael Niedermayer April 6, 2017, 5:29 p.m. UTC | #1
On Thu, Apr 06, 2017 at 10:44:51AM +0200, Nicolas George wrote:
> Signed-off-by: Nicolas George <george@nsup.org>
> ---
>  ffmpeg.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> 
> With this change, filters have a timestamp when EOF is reached, available in
> link->current_pts. For example, vf_fps could make use of it to fix the
> duration of the last frame; the logic in vf_fps seems unnecessarily
> complicated, I have not yet implemented this, but a quick fix could be
> possible.

should be ok

thx

[...]
diff mbox

Patch

diff --git a/ffmpeg.c b/ffmpeg.c
index 41f1f076ca..45d477dcf4 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2212,14 +2212,14 @@  static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame)
     return 0;
 }
 
-static int ifilter_send_eof(InputFilter *ifilter)
+static int ifilter_send_eof(InputFilter *ifilter, int64_t pts)
 {
     int i, j, ret;
 
     ifilter->eof = 1;
 
     if (ifilter->filter) {
-        ret = av_buffersrc_add_frame_flags(ifilter->filter, NULL, AV_BUFFERSRC_FLAG_PUSH);
+        ret = av_buffersrc_close(ifilter->filter, pts, AV_BUFFERSRC_FLAG_PUSH);
         if (ret < 0)
             return ret;
     } else {
@@ -2570,8 +2570,12 @@  out:
 static int send_filter_eof(InputStream *ist)
 {
     int i, ret;
+    /* TODO keep pts also in stream time base to avoid converting back */
+    int64_t pts = av_rescale_q_rnd(ist->pts, AV_TIME_BASE_Q, ist->st->time_base,
+                                   AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX);
+
     for (i = 0; i < ist->nb_filters; i++) {
-        ret = ifilter_send_eof(ist->filters[i]);
+        ret = ifilter_send_eof(ist->filters[i], pts);
         if (ret < 0)
             return ret;
     }