Browse code

ffmpeg: fix overriding codecs with the new syntax

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2012/09/23 00:56:35
Showing 1 changed files
... ...
@@ -54,6 +54,17 @@
54 54
     }\
55 55
 }
56 56
 
57
+#define MATCH_PER_TYPE_OPT(name, type, outvar, fmtctx, mediatype)\
58
+{\
59
+    int i, ret;\
60
+    for (i = 0; i < o->nb_ ## name; i++) {\
61
+        char *spec = o->name[i].specifier;\
62
+        if (!strcmp(spec, mediatype) || !*spec)\
63
+            outvar = o->name[i].u.type;\
64
+        else if (ret < 0)\
65
+            exit_program(1);\
66
+    }\
67
+}
57 68
 char *vstats_filename;
58 69
 
59 70
 float audio_drift_threshold = 0.1;
... ...
@@ -688,6 +699,9 @@ static int opt_input_file(void *optctx, const char *opt, const char *filename)
688 688
     uint8_t buf[128];
689 689
     AVDictionary **opts;
690 690
     int orig_nb_streams;                     // number of streams before avformat_find_stream_info
691
+    char *   video_codec_name = NULL;
692
+    char *   audio_codec_name = NULL;
693
+    char *subtitle_codec_name = NULL;
691 694
 
692 695
     if (o->format) {
693 696
         if (!(file_iformat = av_find_input_format(o->format))) {
... ...
@@ -740,6 +754,10 @@ static int opt_input_file(void *optctx, const char *opt, const char *filename)
740 740
     if (o->nb_frame_pix_fmts)
741 741
         av_dict_set(&format_opts, "pixel_format", o->frame_pix_fmts[o->nb_frame_pix_fmts - 1].u.str, 0);
742 742
 
743
+    MATCH_PER_TYPE_OPT(codec_names, str,    video_codec_name, ic, "v");
744
+    MATCH_PER_TYPE_OPT(codec_names, str,    audio_codec_name, ic, "a");
745
+    MATCH_PER_TYPE_OPT(codec_names, str, subtitle_codec_name, ic, "s");
746
+
743 747
     ic->video_codec_id   = video_codec_name ?
744 748
         find_codec_or_die(video_codec_name   , AVMEDIA_TYPE_VIDEO   , 0)->id : AV_CODEC_ID_NONE;
745 749
     ic->audio_codec_id   = audio_codec_name ?