AVInputFormat *file_iformat = NULL;
int err, i, ret;
int64_t timestamp;
- uint8_t buf[128];
AVDictionary **opts;
AVDictionary *unused_opts = NULL;
AVDictionaryEntry *e = NULL;
exit_program(1);
}
if (o->nb_audio_sample_rate) {
- snprintf(buf, sizeof(buf), "%d", o->audio_sample_rate[o->nb_audio_sample_rate - 1].u.i);
- av_dict_set(&o->g->format_opts, "sample_rate", buf, 0);
+ av_dict_set_int(&o->g->format_opts, "sample_rate", o->audio_sample_rate[o->nb_audio_sample_rate - 1].u.i, 0);
}
if (o->nb_audio_channels) {
/* because we set audio_channels based on both the "ac" and
if (file_iformat && file_iformat->priv_class &&
av_opt_find(&file_iformat->priv_class, "channels", NULL, 0,
AV_OPT_SEARCH_FAKE_OBJ)) {
- snprintf(buf, sizeof(buf), "%d",
- o->audio_channels[o->nb_audio_channels - 1].u.i);
- av_dict_set(&o->g->format_opts, "channels", buf, 0);
+ av_dict_set_int(&o->g->format_opts, "channels", o->audio_channels[o->nb_audio_channels - 1].u.i, 0);
}
}
if (o->nb_frame_rates) {
}
if (!ist || (ist->file_index == map->file_idx && ist->st->index == map->stream_idx)) {
- if (ost->audio_channels_mapped < FF_ARRAY_ELEMS(ost->audio_channels_map))
- ost->audio_channels_map[ost->audio_channels_mapped++] = map->channel_idx;
- else
- av_log(NULL, AV_LOG_FATAL, "Max channel mapping for output %d.%d reached\n",
- ost->file_index, ost->st->index);
+ if (av_reallocp_array(&ost->audio_channels_map,
+ ost->audio_channels_mapped + 1,
+ sizeof(*ost->audio_channels_map)
+ ) < 0 )
+ exit_program(1);
+
+ ost->audio_channels_map[ost->audio_channels_mapped++] = map->channel_idx;
}
}
}
const AVClass *class = avcodec_get_class();
const AVOption *option = av_opt_find(&class, e->key, NULL, 0,
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
- if (!option)
+ const AVClass *fclass = avformat_get_class();
+ const AVOption *foption = av_opt_find(&fclass, e->key, NULL, 0,
+ AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
+ if (!option || foption)
continue;
+
+
if (!(option->flags & AV_OPT_FLAG_ENCODING_PARAM)) {
av_log(NULL, AV_LOG_ERROR, "Codec AVOption %s (%s) specified for "
"output file #%d (%s) is not an encoding option.\n", e->key,
assert_file_overwrite(filename);
if (o->mux_preload) {
- uint8_t buf[64];
- snprintf(buf, sizeof(buf), "%d", (int)(o->mux_preload*AV_TIME_BASE));
- av_dict_set(&of->opts, "preload", buf, 0);
+ av_dict_set_int(&of->opts, "preload", o->mux_preload*AV_TIME_BASE, 0);
}
oc->max_delay = (int)(o->mux_max_delay * AV_TIME_BASE);
parse_option(o, "s", norm == PAL ? "352x288" : "352x240", options);
parse_option(o, "r", frame_rates[norm], options);
- av_dict_set(&o->g->codec_opts, "g", norm == PAL ? "15" : "18", AV_DICT_DONT_OVERWRITE);
+ opt_default(NULL, "g", norm == PAL ? "15" : "18");
- av_dict_set(&o->g->codec_opts, "b:v", "1150000", AV_DICT_DONT_OVERWRITE);
- av_dict_set(&o->g->codec_opts, "maxrate", "1150000", AV_DICT_DONT_OVERWRITE);
- av_dict_set(&o->g->codec_opts, "minrate", "1150000", AV_DICT_DONT_OVERWRITE);
- av_dict_set(&o->g->codec_opts, "bufsize", "327680", AV_DICT_DONT_OVERWRITE); // 40*1024*8;
+ opt_default(NULL, "b:v", "1150000");
+ opt_default(NULL, "maxrate", "1150000");
+ opt_default(NULL, "minrate", "1150000");
+ opt_default(NULL, "bufsize", "327680"); // 40*1024*8;
- av_dict_set(&o->g->codec_opts, "b:a", "224000", AV_DICT_DONT_OVERWRITE);
+ opt_default(NULL, "b:a", "224000");
parse_option(o, "ar", "44100", options);
parse_option(o, "ac", "2", options);
- av_dict_set(&o->g->format_opts, "packetsize", "2324", AV_DICT_DONT_OVERWRITE);
- av_dict_set(&o->g->format_opts, "muxrate", "1411200", AV_DICT_DONT_OVERWRITE); // 2352 * 75 * 8;
+ opt_default(NULL, "packetsize", "2324");
+ opt_default(NULL, "muxrate", "1411200"); // 2352 * 75 * 8;
/* We have to offset the PTS, so that it is consistent with the SCR.
SCR starts at 36000, but the first two packs contain only padding
parse_option(o, "s", norm == PAL ? "480x576" : "480x480", options);
parse_option(o, "r", frame_rates[norm], options);
parse_option(o, "pix_fmt", "yuv420p", options);
- av_dict_set(&o->g->codec_opts, "g", norm == PAL ? "15" : "18", AV_DICT_DONT_OVERWRITE);
+ opt_default(NULL, "g", norm == PAL ? "15" : "18");
- av_dict_set(&o->g->codec_opts, "b:v", "2040000", AV_DICT_DONT_OVERWRITE);
- av_dict_set(&o->g->codec_opts, "maxrate", "2516000", AV_DICT_DONT_OVERWRITE);
- av_dict_set(&o->g->codec_opts, "minrate", "0", AV_DICT_DONT_OVERWRITE); // 1145000;
- av_dict_set(&o->g->codec_opts, "bufsize", "1835008", AV_DICT_DONT_OVERWRITE); // 224*1024*8;
- av_dict_set(&o->g->codec_opts, "scan_offset", "1", AV_DICT_DONT_OVERWRITE);
+ opt_default(NULL, "b:v", "2040000");
+ opt_default(NULL, "maxrate", "2516000");
+ opt_default(NULL, "minrate", "0"); // 1145000;
+ opt_default(NULL, "bufsize", "1835008"); // 224*1024*8;
+ opt_default(NULL, "scan_offset", "1");
- av_dict_set(&o->g->codec_opts, "b:a", "224000", AV_DICT_DONT_OVERWRITE);
+ opt_default(NULL, "b:a", "224000");
parse_option(o, "ar", "44100", options);
- av_dict_set(&o->g->format_opts, "packetsize", "2324", AV_DICT_DONT_OVERWRITE);
+ opt_default(NULL, "packetsize", "2324");
} else if (!strcmp(arg, "dvd")) {
parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);
parse_option(o, "r", frame_rates[norm], options);
parse_option(o, "pix_fmt", "yuv420p", options);
- av_dict_set(&o->g->codec_opts, "g", norm == PAL ? "15" : "18", AV_DICT_DONT_OVERWRITE);
+ opt_default(NULL, "g", norm == PAL ? "15" : "18");
- av_dict_set(&o->g->codec_opts, "b:v", "6000000", AV_DICT_DONT_OVERWRITE);
- av_dict_set(&o->g->codec_opts, "maxrate", "9000000", AV_DICT_DONT_OVERWRITE);
- av_dict_set(&o->g->codec_opts, "minrate", "0", AV_DICT_DONT_OVERWRITE); // 1500000;
- av_dict_set(&o->g->codec_opts, "bufsize", "1835008", AV_DICT_DONT_OVERWRITE); // 224*1024*8;
+ opt_default(NULL, "b:v", "6000000");
+ opt_default(NULL, "maxrate", "9000000");
+ opt_default(NULL, "minrate", "0"); // 1500000;
+ opt_default(NULL, "bufsize", "1835008"); // 224*1024*8;
- av_dict_set(&o->g->format_opts, "packetsize", "2048", AV_DICT_DONT_OVERWRITE); // from www.mpucoder.com: DVD sectors contain 2048 bytes of data, this is also the size of one pack.
- av_dict_set(&o->g->format_opts, "muxrate", "10080000", AV_DICT_DONT_OVERWRITE); // from mplex project: data_rate = 1260000. mux_rate = data_rate * 8
+ opt_default(NULL, "packetsize", "2048"); // from www.mpucoder.com: DVD sectors contain 2048 bytes of data, this is also the size of one pack.
+ opt_default(NULL, "muxrate", "10080000"); // from mplex project: data_rate = 1260000. mux_rate = data_rate * 8
- av_dict_set(&o->g->codec_opts, "b:a", "448000", AV_DICT_DONT_OVERWRITE);
+ opt_default(NULL, "b:a", "448000");
parse_option(o, "ar", "48000", options);
} else if (!strncmp(arg, "dv", 2)) {
av_log(NULL, AV_LOG_ERROR, "Unknown target: %s\n", arg);
return AVERROR(EINVAL);
}
+
+ av_dict_copy(&o->g->codec_opts, codec_opts, AV_DICT_DONT_OVERWRITE);
+ av_dict_copy(&o->g->format_opts, format_opts, AV_DICT_DONT_OVERWRITE);
+
return 0;
}