浏览代码

fftools/ffmpeg: update the reported timestamp at the end

Reported-by: microchip
Anton Khirnov 1 年之前
父节点
当前提交
2305091a3a
共有 3 个文件被更改,包括 10 次插入7 次删除
  1. 1 1
      fftools/ffmpeg.c
  2. 8 5
      fftools/ffmpeg_sched.c
  3. 1 1
      fftools/ffmpeg_sched.h

+ 1 - 1
fftools/ffmpeg.c

@@ -941,7 +941,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++) {

+ 8 - 5
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];
@@ -1200,7 +1203,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);
 

+ 1 - 1
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.