---
This would allow to copy data streams when transcoding, optionally disabling
it with -dn. I am not sure how much this would be appreciated, considering
that data streams are not perfectly integrated. So it could also make sense
to have an inverted switch that copies data streams only when enabled
(-dy maybe?).
Opinions?
Vittorio

 avconv_opt.c | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/avconv_opt.c b/avconv_opt.c
index 1625429..4620b8c 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -869,12 +869,18 @@ static void choose_encoder(OptionsContext *o, 
AVFormatContext *s, OutputStream *
 
     MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st);
     if (!codec_name) {
-        ost->st->codec->codec_id = av_guess_codec(s->oformat, NULL, 
s->filename,
-                                                  NULL, 
ost->st->codec->codec_type);
-        ost->enc = avcodec_find_encoder(ost->st->codec->codec_id);
-    } else if (!strcmp(codec_name, "copy"))
+        if (ost->st->codec->codec_type == AVMEDIA_TYPE_DATA &&
+            !o->data_disable) {
+            ost->stream_copy = 1;
+        } else {
+            ost->st->codec->codec_id =
+                av_guess_codec(s->oformat, NULL, s->filename,
+                               NULL, ost->st->codec->codec_type);
+            ost->enc = avcodec_find_encoder(ost->st->codec->codec_id);
+        }
+    } else if (!strcmp(codec_name, "copy")) {
         ost->stream_copy = 1;
-    else {
+    } else {
         ost->enc = find_codec_or_die(codec_name, ost->st->codec->codec_type, 
1);
         ost->st->codec->codec_id = ost->enc->id;
     }
@@ -1444,6 +1450,7 @@ static int open_output_file(OptionsContext *o, const char 
*filename)
             case AVMEDIA_TYPE_VIDEO:    o->video_disable    = 1; break;
             case AVMEDIA_TYPE_AUDIO:    o->audio_disable    = 1; break;
             case AVMEDIA_TYPE_SUBTITLE: o->subtitle_disable = 1; break;
+            case AVMEDIA_TYPE_DATA:     o->data_disable     = 1; break;
             }
             init_output_filter(ofilter, o, oc);
         }
@@ -1496,7 +1503,16 @@ static int open_output_file(OptionsContext *o, const 
char *filename)
                     break;
                 }
         }
-        /* do something with data? */
+
+        /* copy data streams unless disabled */
+        if (!o->data_disable) {
+            for (i = 0; i < nb_input_streams; i++) {
+                if (input_streams[i]->st->codec->codec_type == 
AVMEDIA_TYPE_DATA) {
+                    NEW_STREAM(data, i);
+                    break;
+                }
+            }
+        }
     } else {
         for (i = 0; i < o->nb_stream_maps; i++) {
             StreamMap *map = &o->stream_maps[i];
@@ -2426,6 +2442,8 @@ const OptionDef options[] = {
     /* data codec support */
     { "dcodec", HAS_ARG | OPT_DATA | OPT_PERFILE | OPT_EXPERT | OPT_INPUT | 
OPT_OUTPUT, { .func_arg = opt_data_codec },
         "force data codec ('copy' to copy stream)", "codec" },
+    { "dn",     OPT_AUDIO | OPT_BOOL | OPT_OFFSET | OPT_OUTPUT,
+        { .off = OFFSET(data_disable) }, "disable data streams" },
 
     { NULL, },
 };
-- 
1.9.5 (Apple Git-50.3)

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to