[FFmpeg-cvslog] ffmpeg: fix overriding codecs with the new syntax

Michael Niedermayer git at videolan.org
Sat Sep 22 18:06:00 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat Sep 22 17:56:35 2012 +0200| [bad953bc2df5e97a3c02ecff0d652bb4626512e8] | committer: Michael Niedermayer

ffmpeg: fix overriding codecs with the new syntax

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

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

 ffmpeg_opt.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index f337a91..db5926a 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -54,6 +54,17 @@
     }\
 }
 
+#define MATCH_PER_TYPE_OPT(name, type, outvar, fmtctx, mediatype)\
+{\
+    int i, ret;\
+    for (i = 0; i < o->nb_ ## name; i++) {\
+        char *spec = o->name[i].specifier;\
+        if (!strcmp(spec, mediatype) || !*spec)\
+            outvar = o->name[i].u.type;\
+        else if (ret < 0)\
+            exit_program(1);\
+    }\
+}
 char *vstats_filename;
 
 float audio_drift_threshold = 0.1;
@@ -688,6 +699,9 @@ static int opt_input_file(void *optctx, const char *opt, const char *filename)
     uint8_t buf[128];
     AVDictionary **opts;
     int orig_nb_streams;                     // number of streams before avformat_find_stream_info
+    char *   video_codec_name = NULL;
+    char *   audio_codec_name = NULL;
+    char *subtitle_codec_name = NULL;
 
     if (o->format) {
         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)
     if (o->nb_frame_pix_fmts)
         av_dict_set(&format_opts, "pixel_format", o->frame_pix_fmts[o->nb_frame_pix_fmts - 1].u.str, 0);
 
+    MATCH_PER_TYPE_OPT(codec_names, str,    video_codec_name, ic, "v");
+    MATCH_PER_TYPE_OPT(codec_names, str,    audio_codec_name, ic, "a");
+    MATCH_PER_TYPE_OPT(codec_names, str, subtitle_codec_name, ic, "s");
+
     ic->video_codec_id   = video_codec_name ?
         find_codec_or_die(video_codec_name   , AVMEDIA_TYPE_VIDEO   , 0)->id : AV_CODEC_ID_NONE;
     ic->audio_codec_id   = audio_codec_name ?



More information about the ffmpeg-cvslog mailing list