[FFmpeg-cvslog] avconv: make -shortest work with streamcopy

Anton Khirnov git at videolan.org
Fri Jun 20 01:10:52 CEST 2014


ffmpeg | branch: release/1.1 | Anton Khirnov <anton at khirnov.net> | Tue Jun 10 17:41:57 2014 +0200| [e0fcad77618a0455ca9c2451ea0aa538597a08c0] | committer: Anton Khirnov

avconv: make -shortest work with streamcopy

CC: libav-stable at libav.org
(cherry picked from commit 48e50921337984ba4ec2c1cafe45d43787f84498)

Signed-off-by: Anton Khirnov <anton at khirnov.net>

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

 avconv.c |   27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/avconv.c b/avconv.c
index 6544fc6..ad64c52 100644
--- a/avconv.c
+++ b/avconv.c
@@ -720,6 +720,19 @@ static int poll_filter(OutputStream *ost)
     return 0;
 }
 
+static void finish_output_stream(OutputStream *ost)
+{
+    OutputFile *of = output_files[ost->file_index];
+    int i;
+
+    ost->finished = 1;
+
+    if (of->shortest) {
+        for (i = 0; i < of->ctx->nb_streams; i++)
+            output_streams[of->ost_index + i]->finished = 1;
+    }
+}
+
 /*
  * Read as many frames from possible from lavfi and encode them.
  *
@@ -730,7 +743,7 @@ static int poll_filter(OutputStream *ost)
  */
 static int poll_filters(void)
 {
-    int i, j, ret = 0;
+    int i, ret = 0;
 
     while (ret >= 0 && !received_sigterm) {
         OutputStream *ost = NULL;
@@ -757,15 +770,7 @@ static int poll_filters(void)
         ret = poll_filter(ost);
 
         if (ret == AVERROR_EOF) {
-            OutputFile *of = output_files[ost->file_index];
-
-            ost->finished = 1;
-
-            if (of->shortest) {
-                for (j = 0; j < of->ctx->nb_streams; j++)
-                    output_streams[of->ost_index + j]->finished = 1;
-            }
-
+            finish_output_stream(ost);
             ret = 0;
         } else if (ret == AVERROR(EAGAIN))
             return 0;
@@ -2127,7 +2132,7 @@ static int process_input(void)
 
                 if (ost->source_index == ifile->ist_index + i &&
                     (ost->stream_copy || ost->enc->type == AVMEDIA_TYPE_SUBTITLE))
-                    ost->finished= 1;
+                    finish_output_stream(ost);
             }
         }
 



More information about the ffmpeg-cvslog mailing list