[FFmpeg-cvslog] avconv: make -shortest a per-output file option.

Anton Khirnov git at videolan.org
Sat Aug 18 15:26:30 CEST 2012


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sat Aug 11 11:50:32 2012 +0200| [3c0df9058438b68925be2fc6f5af2a05086ad99e] | committer: Anton Khirnov

avconv: make -shortest a per-output file option.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3c0df9058438b68925be2fc6f5af2a05086ad99e
---

 Changelog       |    1 +
 avconv.c        |   15 ++++++++-------
 avconv.h        |    4 +++-
 avconv_opt.c    |    3 ++-
 doc/avconv.texi |    2 +-
 5 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/Changelog b/Changelog
index 64c23d3..4d0a9f5 100644
--- a/Changelog
+++ b/Changelog
@@ -42,6 +42,7 @@ version <next>:
 - RTMPE protocol support
 - RTMPTE protocol support
 - Canopus Lossless Codec decoder
+- avconv -shortest option is now per-output file
 
 
 version 0.8:
diff --git a/avconv.c b/avconv.c
index 83ff8b4..735fc3e 100644
--- a/avconv.c
+++ b/avconv.c
@@ -719,7 +719,7 @@ static int poll_filter(OutputStream *ost)
  */
 static int poll_filters(void)
 {
-    int i, ret = 0;
+    int i, j, ret = 0;
 
     while (ret >= 0 && !received_sigterm) {
         OutputStream *ost = NULL;
@@ -746,10 +746,14 @@ static int poll_filters(void)
         ret = poll_filter(ost);
 
         if (ret == AVERROR_EOF) {
+            OutputFile *of = output_files[ost->file_index];
+
             ost->finished = 1;
 
-            if (opt_shortest)
-                return ret;
+            if (of->shortest) {
+                for (j = 0; j < of->ctx->nb_streams; j++)
+                    output_streams[of->ost_index + j]->finished = 1;
+            }
 
             ret = 0;
         } else if (ret == AVERROR(EAGAIN))
@@ -2170,10 +2174,7 @@ static int process_input(void)
             }
         }
 
-        if (opt_shortest)
-            return AVERROR_EOF;
-        else
-            return AVERROR(EAGAIN);
+        return AVERROR(EAGAIN);
     }
 
     reset_eagain();
diff --git a/avconv.h b/avconv.h
index 756d197..94b3f67 100644
--- a/avconv.h
+++ b/avconv.h
@@ -113,6 +113,7 @@ typedef struct OptionsContext {
     uint64_t limit_filesize;
     float mux_preload;
     float mux_max_delay;
+    int shortest;
 
     int video_disable;
     int audio_disable;
@@ -303,6 +304,8 @@ typedef struct OutputFile {
     int64_t recording_time; /* desired length of the resulting file in microseconds */
     int64_t start_time;     /* start time in microseconds */
     uint64_t limit_filesize;
+
+    int shortest;
 } OutputFile;
 
 extern InputStream **input_streams;
@@ -333,7 +336,6 @@ extern int do_hex_dump;
 extern int do_pkt_dump;
 extern int copy_ts;
 extern int copy_tb;
-extern int opt_shortest;
 extern int exit_on_error;
 extern int print_stats;
 extern int qp_hist;
diff --git a/avconv_opt.c b/avconv_opt.c
index 7b86d76..dc44986 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -1352,6 +1352,7 @@ loop_end:
         oc->duration = o->recording_time;
     output_files[nb_output_files - 1]->start_time     = o->start_time;
     output_files[nb_output_files - 1]->limit_filesize = o->limit_filesize;
+    output_files[nb_output_files - 1]->shortest       = o->shortest;
     av_dict_copy(&output_files[nb_output_files - 1]->opts, format_opts, 0);
 
     /* check filename in case of an image number is expected */
@@ -1836,7 +1837,7 @@ const OptionDef options[] = {
     { "adrift_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {(void*)&audio_drift_threshold}, "audio drift threshold", "threshold" },
     { "copyts", OPT_BOOL | OPT_EXPERT, {(void*)&copy_ts}, "copy timestamps" },
     { "copytb", OPT_BOOL | OPT_EXPERT, {(void*)&copy_tb}, "copy input stream time base when stream copying" },
-    { "shortest", OPT_BOOL | OPT_EXPERT, {(void*)&opt_shortest}, "finish encoding within shortest input" }, //
+    { "shortest", OPT_BOOL | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(shortest)}, "finish encoding within shortest input" },
     { "dts_delta_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {(void*)&dts_delta_threshold}, "timestamp discontinuity delta threshold", "threshold" },
     { "xerror", OPT_BOOL, {(void*)&exit_on_error}, "exit on error", "error" },
     { "copyinkf", OPT_BOOL | OPT_EXPERT | OPT_SPEC, {.off = OFFSET(copy_initial_nonkeyframes)}, "copy initial non-keyframes" },
diff --git a/doc/avconv.texi b/doc/avconv.texi
index ff5bb52..fc64028 100644
--- a/doc/avconv.texi
+++ b/doc/avconv.texi
@@ -752,7 +752,7 @@ This option has been deprecated. Use the @code{asyncts} audio filter instead.
 Copy timestamps from input to output.
 @item -copytb
 Copy input stream time base from input to output when stream copying.
- at item -shortest
+ at item -shortest (@emph{output})
 Finish encoding when the shortest input stream ends.
 @item -dts_delta_threshold
 Timestamp discontinuity delta threshold.



More information about the ffmpeg-cvslog mailing list