]> git.sesse.net Git - ffmpeg/blobdiff - ffmpeg_opt.c
nellymoserenc: Fix assignments in if()
[ffmpeg] / ffmpeg_opt.c
index 6867a0073a4166d9e2c562d41d65d6123f2a70b2..c98e03063b067079d4832b1169c3e2023f4e20f0 100644 (file)
@@ -95,6 +95,8 @@ static int intra_dc_precision = 8;
 static int do_psnr            = 0;
 static int input_sync;
 
+static int64_t recording_time = INT64_MAX;
+
 static void uninit_options(OptionsContext *o, int is_input)
 {
     const OptionDef *po = options;
@@ -125,21 +127,21 @@ static void uninit_options(OptionsContext *o, int is_input)
     av_freep(&o->audio_channel_maps);
     av_freep(&o->streamid_map);
 
-    if (!is_input)
-        o->recording_time = INT64_MAX;
+    if (is_input)
+        recording_time = o->recording_time;
+    else
+        recording_time = INT64_MAX;
 }
 
 static void init_options(OptionsContext *o, int is_input)
 {
-    OptionsContext bak= *o;
     memset(o, 0, sizeof(*o));
 
-    if (!is_input) {
-        o->recording_time = bak.recording_time;
-        if (o->recording_time != INT64_MAX)
-            av_log(NULL, AV_LOG_WARNING,
-                   "-t is not an input option, keeping it for the next output;"
-                   " consider fixing your command line.\n");
+    if (!is_input && recording_time != INT64_MAX) {
+        o->recording_time = recording_time;
+        av_log(NULL, AV_LOG_WARNING,
+                "-t is not an input option, keeping it for the next output;"
+                " consider fixing your command line.\n");
     } else
     o->recording_time = INT64_MAX;
     o->mux_max_delay  = 0.7;
@@ -569,7 +571,6 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
         ist->file_index = nb_input_files;
         ist->discard = 1;
         st->discard  = AVDISCARD_ALL;
-        ist->opts = filter_codec_opts(o->g->codec_opts, ist->st->codec->codec_id, ic, st, choose_decoder(o, ic, st));
 
         ist->ts_scale = 1.0;
         MATCH_PER_STREAM_OPT(ts_scale, dbl, ist->ts_scale, ic, st);
@@ -583,6 +584,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
         }
 
         ist->dec = choose_decoder(o, ic, st);
+        ist->opts = filter_codec_opts(o->g->codec_opts, ist->st->codec->codec_id, ic, st, ist->dec);
 
         ist->reinit_filters = -1;
         MATCH_PER_STREAM_OPT(reinit_filters, i, ist->reinit_filters, ic, st);
@@ -1012,6 +1014,8 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
     av_opt_get_int   (o->g->swr_opts, "filter_type"  , 0, &ost->swr_filter_type);
     av_opt_get_int   (o->g->swr_opts, "dither_method", 0, &ost->swr_dither_method);
     av_opt_get_double(o->g->swr_opts, "dither_scale" , 0, &ost->swr_dither_scale);
+    if (ost->enc && av_get_exact_bits_per_sample(ost->enc->id) == 24)
+        ost->swr_dither_scale = ost->swr_dither_scale*256;
 
     ost->source_index = source_index;
     if (source_index >= 0) {
@@ -1583,7 +1587,7 @@ static int open_output_file(OptionsContext *o, const char *filename)
 loop_end:
                 if (!ofilter) {
                     av_log(NULL, AV_LOG_FATAL, "Output with label '%s' does not exist "
-                           "in any defined filter graph.\n", map->linklabel);
+                           "in any defined filter graph, or was already used elsewhere.\n", map->linklabel);
                     exit(1);
                 }
                 init_output_filter(ofilter, o, oc);
@@ -1613,18 +1617,6 @@ loop_end:
         }
     }
 
-
-    for (i = nb_output_streams - oc->nb_streams; i < nb_output_streams; i++) { //for all streams of this output file
-        AVDictionaryEntry *e;
-        ost = output_streams[i];
-
-        if (   ost->stream_copy
-            && (e = av_dict_get(o->g->codec_opts, "flags", NULL, AV_DICT_IGNORE_SUFFIX))
-            && (!e->key[5] || check_stream_specifier(oc, ost->st, e->key+6)))
-            if (av_opt_set(ost->st->codec, "flags", e->value, 0) < 0)
-                exit(1);
-    }
-
     /* handle attached files */
     for (i = 0; i < o->nb_attachments; i++) {
         AVIOContext *pb;
@@ -1652,6 +1644,7 @@ loop_end:
         ost = new_attachment_stream(o, oc, -1);
         ost->stream_copy               = 0;
         ost->attachment_filename       = o->attachments[i];
+        ost->finished                  = 1;
         ost->st->codec->extradata      = attachment;
         ost->st->codec->extradata_size = len;
 
@@ -1660,6 +1653,17 @@ loop_end:
         avio_close(pb);
     }
 
+    for (i = nb_output_streams - oc->nb_streams; i < nb_output_streams; i++) { //for all streams of this output file
+        AVDictionaryEntry *e;
+        ost = output_streams[i];
+
+        if ((ost->stream_copy || ost->attachment_filename)
+            && (e = av_dict_get(o->g->codec_opts, "flags", NULL, AV_DICT_IGNORE_SUFFIX))
+            && (!e->key[5] || check_stream_specifier(oc, ost->st, e->key+6)))
+            if (av_opt_set(ost->st->codec, "flags", e->value, 0) < 0)
+                exit(1);
+    }
+
     GROW_ARRAY(output_files, nb_output_files);
     if (!(output_files[nb_output_files - 1] = av_mallocz(sizeof(*output_files[0]))))
         exit(1);
@@ -1978,8 +1982,8 @@ static int opt_data_frames(void *optctx, const char *opt, const char *arg)
 static int opt_default_new(OptionsContext *o, const char *opt, const char *arg)
 {
     int ret;
-    AVCodecContext *cbak = codec_opts;
-    AVCodecContext *fbak = format_opts;
+    AVDictionary *cbak = codec_opts;
+    AVDictionary *fbak = format_opts;
     codec_opts = NULL;
     format_opts = NULL;
 
@@ -2266,7 +2270,6 @@ enum OptGroup {
 static const OptionGroupDef groups[] = {
     [GROUP_OUTFILE] = { "output file",  NULL },
     [GROUP_INFILE]  = { "input file",   "i"  },
-    { 0 },
 };
 
 static int open_files(OptionGroupList *l, const char *inout,
@@ -2311,7 +2314,8 @@ int ffmpeg_parse_options(int argc, char **argv)
     memset(&octx, 0, sizeof(octx));
 
     /* split the commandline into an internal representation */
-    ret = split_commandline(&octx, argc, argv, options, groups);
+    ret = split_commandline(&octx, argc, argv, options, groups,
+                            FF_ARRAY_ELEMS(groups));
     if (ret < 0) {
         av_log(NULL, AV_LOG_FATAL, "Error splitting the argument list: ");
         goto fail;
@@ -2459,7 +2463,7 @@ const OptionDef options[] = {
     { "profile",        HAS_ARG | OPT_EXPERT | OPT_PERFILE,          { .func_arg = opt_profile },
         "set profile", "profile" },
     { "filter",         HAS_ARG | OPT_STRING | OPT_SPEC,             { .off = OFFSET(filters) },
-        "set stream filterchain", "filter_list" },
+        "set stream filtergraph", "filter_graph" },
     { "reinit_filter",  HAS_ARG | OPT_INT | OPT_SPEC,                { .off = OFFSET(reinit_filters) },
         "reinit filtergraph on input parameter changes", "" },
     { "filter_complex", HAS_ARG | OPT_EXPERT,                        { .func_arg = opt_filter_complex },
@@ -2533,7 +2537,7 @@ const OptionDef options[] = {
     { "vstats_file",  OPT_VIDEO | HAS_ARG | OPT_EXPERT ,                         { opt_vstats_file },
         "dump video coding statistics to file", "file" },
     { "vf",           OPT_VIDEO | HAS_ARG  | OPT_PERFILE,                        { .func_arg = opt_video_filters },
-        "video filters", "filter list" },
+        "set video filters", "filter_graph" },
     { "intra_matrix", OPT_VIDEO | HAS_ARG | OPT_EXPERT  | OPT_STRING | OPT_SPEC, { .off = OFFSET(intra_matrices) },
         "specify intra matrix coeffs", "matrix" },
     { "inter_matrix", OPT_VIDEO | HAS_ARG | OPT_EXPERT  | OPT_STRING | OPT_SPEC, { .off = OFFSET(inter_matrices) },
@@ -2578,7 +2582,7 @@ const OptionDef options[] = {
     { "channel_layout", OPT_AUDIO | HAS_ARG  | OPT_EXPERT | OPT_PERFILE,           { .func_arg = opt_channel_layout },
         "set channel layout", "layout" },
     { "af",             OPT_AUDIO | HAS_ARG  | OPT_PERFILE,                        { .func_arg = opt_audio_filters },
-        "audio filters", "filter list" },
+        "set audio filters", "filter_graph" },
 
     /* subtitle options */
     { "sn",     OPT_SUBTITLE | OPT_BOOL | OPT_OFFSET, { .off = OFFSET(subtitle_disable) },