Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 11/12] fftools/ffmpeg: update the reported timestamp at the end
Date: Wed, 13 Dec 2023 20:30:06 +0100
Message-ID: <20231213193007.17471-11-anton@khirnov.net> (raw)
In-Reply-To: <20231213193007.17471-1-anton@khirnov.net>

Reported-by: microchip
---
 fftools/ffmpeg.c       |  2 +-
 fftools/ffmpeg_sched.c | 13 ++++++++-----
 fftools/ffmpeg_sched.h |  2 +-
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 8077248254..4c706eb46a 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -926,7 +926,7 @@ static int transcode(Scheduler *sch)
         print_report(0, timer_start, cur_time, transcode_ts);
     }
 
-    ret = sch_stop(sch);
+    ret = sch_stop(sch, &transcode_ts);
 
     /* write the trailer if needed */
     for (i = 0; i < nb_output_files; i++) {
diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c
index ab14d6233e..b1c7db776e 100644
--- a/fftools/ffmpeg_sched.c
+++ b/fftools/ffmpeg_sched.c
@@ -423,7 +423,7 @@ static void task_init(Scheduler *sch, SchTask *task, enum SchedulerNodeType type
     task->func_arg  = func_arg;
 }
 
-static int64_t trailing_dts(const Scheduler *sch)
+static int64_t trailing_dts(const Scheduler *sch, int count_finished)
 {
     int64_t min_dts = INT64_MAX;
 
@@ -433,7 +433,7 @@ static int64_t trailing_dts(const Scheduler *sch)
         for (unsigned j = 0; j < mux->nb_streams; j++) {
             const SchMuxStream *ms = &mux->streams[j];
 
-            if (ms->source_finished)
+            if (ms->source_finished && !count_finished)
                 continue;
             if (ms->last_dts == AV_NOPTS_VALUE)
                 return AV_NOPTS_VALUE;
@@ -445,7 +445,7 @@ static int64_t trailing_dts(const Scheduler *sch)
     return min_dts == INT64_MAX ? AV_NOPTS_VALUE : min_dts;
 }
 
-int sch_stop(Scheduler *sch)
+int sch_stop(Scheduler *sch, int64_t *finish_ts)
 {
     int ret = 0, err;
 
@@ -492,6 +492,9 @@ int sch_stop(Scheduler *sch)
         ret = err_merge(ret, err);
     }
 
+    if (finish_ts)
+        *finish_ts = trailing_dts(sch, 1);
+
     return ret;
 }
 
@@ -502,7 +505,7 @@ void sch_free(Scheduler **psch)
     if (!sch)
         return;
 
-    sch_stop(sch);
+    sch_stop(sch, NULL);
 
     for (unsigned i = 0; i < sch->nb_demux; i++) {
         SchDemux *d = &sch->demux[i];
@@ -1194,7 +1197,7 @@ static void schedule_update_locked(Scheduler *sch)
     if (atomic_load(&sch->terminate))
         return;
 
-    dts = trailing_dts(sch);
+    dts = trailing_dts(sch, 0);
 
     atomic_store(&sch->last_dts, dts);
 
diff --git a/fftools/ffmpeg_sched.h b/fftools/ffmpeg_sched.h
index 94bbd30e98..b167d8d158 100644
--- a/fftools/ffmpeg_sched.h
+++ b/fftools/ffmpeg_sched.h
@@ -127,7 +127,7 @@ Scheduler *sch_alloc(void);
 void sch_free(Scheduler **sch);
 
 int sch_start(Scheduler *sch);
-int sch_stop(Scheduler *sch);
+int sch_stop(Scheduler *sch, int64_t *finish_ts);
 
 /**
  * Wait until transcoding terminates or the specified timeout elapses.
-- 
2.42.0

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

  parent reply	other threads:[~2023-12-13 19:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-13 19:29 [FFmpeg-devel] [PATCH 01/12] fftools/ffmpeg_filter: move FilterGraph.graph to FilterGraphThread Anton Khirnov
2023-12-13 19:29 ` [FFmpeg-devel] [PATCH 02/12] fftools/ffmpeg: replace InputStream.file_index by a pointer Anton Khirnov
2023-12-13 19:29 ` [FFmpeg-devel] [PATCH 03/12] fftools/ffmpeg: replace OutputStream.file_index " Anton Khirnov
2023-12-14 19:20   ` Michael Niedermayer
2023-12-14 19:34     ` Anton Khirnov
2023-12-14 19:53       ` James Almer
2023-12-13 19:29 ` [FFmpeg-devel] [PATCH 04/12] fftools/ffmpeg: move InputStream.discard to private data Anton Khirnov
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 05/12] fftools/ffmpeg: move InputStream.codec_desc " Anton Khirnov
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 06/12] fftools/ffmpeg: drop unused InputFile.eof_reached Anton Khirnov
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 07/12] fftools/ffmpeg_demux: move InputFile.readrate to private data Anton Khirnov
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 08/12] fftools/ffmpeg_mux: move OutputStream.sq_idx_mux " Anton Khirnov
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 09/12] fftools/ffmpeg: drop OutputFile.sq_encode Anton Khirnov
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 10/12] fftools/ffmpeg_sched: move trailing_dts() higher up Anton Khirnov
2023-12-13 19:30 ` Anton Khirnov [this message]
2023-12-13 19:30 ` [FFmpeg-devel] [PATCH 12/12] fftools/ffmpeg_sched: track dts+duration as last_dts Anton Khirnov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231213193007.17471-11-anton@khirnov.net \
    --to=anton@khirnov.net \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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