[FFmpeg-devel] [PATCH 2/2] ffmpeg: Avoid matching attachment pics to video on wildcard maps.

Michael Niedermayer michaelni at gmx.at
Sun Feb 3 01:31:58 CET 2013


If a map matches multiple streams skip attachment pics if the
output format does not appear to support them, similarly skip
video in this case if the output formats seems to only support
attachment pics.

Fixes Ticket2227

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 ffmpeg.h     |    1 +
 ffmpeg_opt.c |   10 +++++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ffmpeg.h b/ffmpeg.h
index c64a015..3d751aa 100644
--- a/ffmpeg.h
+++ b/ffmpeg.h
@@ -59,6 +59,7 @@
 /* select an input stream for an output stream */
 typedef struct StreamMap {
     int disabled;           /* 1 is this mapping is disabled by a negative map */
+    int weak;               /* 1 if this mapping is the result of a unspecific map */
     int file_index;
     int stream_index;
     int sync_file_index;
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 79a53ec..685d57c 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -259,7 +259,8 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
                                            *p == ':' ? p + 1 : p) > 0)
                     m->disabled = 1;
             }
-        else
+        else {
+            int last_nb_stream_maps = o->nb_stream_maps;
             for (i = 0; i < input_files[file_idx]->nb_streams; i++) {
                 if (check_stream_specifier(input_files[file_idx]->ctx, input_files[file_idx]->ctx->streams[i],
                             *p == ':' ? p + 1 : p) <= 0)
@@ -278,6 +279,10 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
                     m->sync_stream_index = i;
                 }
             }
+            if (last_nb_stream_maps + 1 < o->nb_stream_maps)
+                for (i = last_nb_stream_maps; i < o->nb_stream_maps; i++)
+                    o->stream_maps[i].weak = 1;
+        }
     }
 
     if (!m) {
@@ -1586,6 +1591,7 @@ loop_end:
                 }
                 init_output_filter(ofilter, o, oc);
             } else {
+                int qcr = avformat_query_codec(oc->oformat, oc->oformat->video_codec, 0);
                 ist = input_streams[input_files[map->file_index]->ist_index + map->stream_index];
                 if(o->subtitle_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE)
                     continue;
@@ -1595,6 +1601,8 @@ loop_end:
                     continue;
                 if(o->    data_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_DATA)
                     continue;
+                if (map->weak && ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && weak_map_score(ist, qcr, 99) < 2)
+                    continue;
 
                 switch (ist->st->codec->codec_type) {
                 case AVMEDIA_TYPE_VIDEO:      ost = new_video_stream     (o, oc, src_idx); break;
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list