int i;
printf("Supported hardware acceleration:\n");
- for (i = 0; i < FF_ARRAY_ELEMS(hwaccels) - 1; i++) {
+ for (i = 0; hwaccels[i].name; i++) {
printf("%s\n", hwaccels[i].name);
}
printf("\n");
switch (par->codec_type) {
case AVMEDIA_TYPE_VIDEO:
- ist->resample_height = ist->dec_ctx->height;
- ist->resample_width = ist->dec_ctx->width;
- ist->resample_pix_fmt = ist->dec_ctx->pix_fmt;
-
MATCH_PER_STREAM_OPT(frame_rates, str, framerate, ic, st);
if (framerate && av_parse_video_rate(&ist->framerate,
framerate) < 0) {
break;
case AVMEDIA_TYPE_AUDIO:
guess_input_channel_layout(ist);
-
- ist->resample_sample_fmt = ist->dec_ctx->sample_fmt;
- ist->resample_sample_rate = ist->dec_ctx->sample_rate;
- ist->resample_channels = ist->dec_ctx->channels;
- ist->resample_channel_layout = ist->dec_ctx->channel_layout;
-
break;
case AVMEDIA_TYPE_DATA:
case AVMEDIA_TYPE_SUBTITLE:
MATCH_PER_STREAM_OPT(bitstream_filters, str, bsfs, oc, st);
while (bsfs && *bsfs) {
const AVBitStreamFilter *filter;
- char *bsf;
+ const char *bsf, *bsf_options_str, *bsf_name;
+ AVDictionary *bsf_options = NULL;
- bsf = av_get_token(&bsfs, ",");
+ bsf = bsf_options_str = av_get_token(&bsfs, ",");
if (!bsf)
exit_program(1);
+ bsf_name = av_get_token(&bsf_options_str, "=");
+ if (!bsf_name)
+ exit_program(1);
- filter = av_bsf_get_by_name(bsf);
+ filter = av_bsf_get_by_name(bsf_name);
if (!filter) {
- av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\n", bsf);
+ av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\n", bsf_name);
exit_program(1);
}
+ if (*bsf_options_str++) {
+ ret = av_dict_parse_string(&bsf_options, bsf_options_str, "=", ":", 0);
+ if (ret < 0) {
+ av_log(NULL, AV_LOG_ERROR, "Error parsing options for bitstream filter %s\n", bsf_name);
+ exit_program(1);
+ }
+ }
av_freep(&bsf);
- ost->bitstream_filters = av_realloc_array(ost->bitstream_filters,
- ost->nb_bitstream_filters + 1,
- sizeof(*ost->bitstream_filters));
- if (!ost->bitstream_filters)
+ ost->bsf_ctx = av_realloc_array(ost->bsf_ctx,
+ ost->nb_bitstream_filters + 1,
+ sizeof(*ost->bsf_ctx));
+ if (!ost->bsf_ctx)
+ exit_program(1);
+
+ ret = av_bsf_alloc(filter, &ost->bsf_ctx[ost->nb_bitstream_filters]);
+ if (ret < 0) {
+ av_log(NULL, AV_LOG_ERROR, "Error allocating a bistream filter context\n");
exit_program(1);
+ }
+ ost->nb_bitstream_filters++;
+
+ if (bsf_options) {
+ ret = av_opt_set_dict(ost->bsf_ctx[ost->nb_bitstream_filters-1]->priv_data, &bsf_options);
+ if (ret < 0) {
+ av_log(NULL, AV_LOG_ERROR, "Error setting options for bitstream filter %s\n", bsf_name);
+ exit_program(1);
+ }
+ assert_avoptions(bsf_options);
+ av_dict_free(&bsf_options);
+ }
+ av_freep(&bsf_name);
- ost->bitstream_filters[ost->nb_bitstream_filters++] = filter;
if (*bsfs)
bsfs++;
}
ost->filter = ofilter;
ofilter->ost = ost;
+ ofilter->format = -1;
if (ost->stream_copy) {
av_log(NULL, AV_LOG_ERROR, "Streamcopy requested for output stream %d:%d, "
return 0;
}
-static int configure_complex_filters(void)
-{
- int i, ret = 0;
-
- for (i = 0; i < nb_filtergraphs; i++)
- if (!filtergraph_is_simple(filtergraphs[i]) &&
- (ret = configure_filtergraph(filtergraphs[i])) < 0)
- return ret;
- return 0;
-}
-
static int open_output_file(OptionsContext *o, const char *filename)
{
AVFormatContext *oc;
}
}
+ /* set the filter output constraints */
+ if (ost->filter) {
+ OutputFilter *f = ost->filter;
+ int count;
+ switch (ost->enc_ctx->codec_type) {
+ case AVMEDIA_TYPE_VIDEO:
+ f->frame_rate = ost->frame_rate;
+ f->width = ost->enc_ctx->width;
+ f->height = ost->enc_ctx->height;
+ if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) {
+ f->format = ost->enc_ctx->pix_fmt;
+ } else if (ost->enc->pix_fmts) {
+ count = 0;
+ while (ost->enc->pix_fmts[count] != AV_PIX_FMT_NONE)
+ count++;
+ f->formats = av_mallocz_array(count + 1, sizeof(*f->formats));
+ if (!f->formats)
+ exit_program(1);
+ memcpy(f->formats, ost->enc->pix_fmts, (count + 1) * sizeof(*f->formats));
+ }
+ break;
+ case AVMEDIA_TYPE_AUDIO:
+ if (ost->enc_ctx->sample_fmt != AV_SAMPLE_FMT_NONE) {
+ f->format = ost->enc_ctx->sample_fmt;
+ } else if (ost->enc->sample_fmts) {
+ count = 0;
+ while (ost->enc->sample_fmts[count] != AV_SAMPLE_FMT_NONE)
+ count++;
+ f->formats = av_mallocz_array(count + 1, sizeof(*f->formats));
+ if (!f->formats)
+ exit_program(1);
+ memcpy(f->formats, ost->enc->sample_fmts, (count + 1) * sizeof(*f->formats));
+ }
+ if (ost->enc_ctx->sample_rate) {
+ f->sample_rate = ost->enc_ctx->sample_rate;
+ } else if (ost->enc->supported_samplerates) {
+ count = 0;
+ while (ost->enc->supported_samplerates[count])
+ count++;
+ f->sample_rates = av_mallocz_array(count + 1, sizeof(*f->sample_rates));
+ if (!f->sample_rates)
+ exit_program(1);
+ memcpy(f->sample_rates, ost->enc->supported_samplerates,
+ (count + 1) * sizeof(*f->sample_rates));
+ }
+ if (ost->enc_ctx->channels) {
+ f->channel_layout = av_get_default_channel_layout(ost->enc_ctx->channels);
+ } else if (ost->enc->channel_layouts) {
+ count = 0;
+ while (ost->enc->channel_layouts[count])
+ count++;
+ f->channel_layouts = av_mallocz_array(count + 1, sizeof(*f->channel_layouts));
+ if (!f->channel_layouts)
+ exit_program(1);
+ memcpy(f->channel_layouts, ost->enc->channel_layouts,
+ (count + 1) * sizeof(*f->channel_layouts));
+ }
+ break;
+ }
+ }
+
}
/* check filename in case of an image number is expected */
goto fail;
}
- /* configure the complex filtergraphs */
- ret = configure_complex_filters();
- if (ret < 0) {
- av_log(NULL, AV_LOG_FATAL, "Error configuring complex filters.\n");
- goto fail;
- }
-
fail:
uninit_parse_context(&octx);
if (ret < 0) {
#define OFFSET(x) offsetof(OptionsContext, x)
const OptionDef options[] = {
/* main options */
-#include "cmdutils_common_opts.h"
+ CMDUTILS_COMMON_OPTIONS
{ "f", HAS_ARG | OPT_STRING | OPT_OFFSET |
OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(format) },
"force format", "fmt" },
{ "target", HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_target },
"specify target file type (\"vcd\", \"svcd\", \"dvd\","
" \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)", "type" },
- { "vsync", HAS_ARG | OPT_EXPERT, { opt_vsync },
+ { "vsync", HAS_ARG | OPT_EXPERT, { .func_arg = opt_vsync },
"video sync method", "" },
{ "async", HAS_ARG | OPT_INT | OPT_EXPERT, { &audio_sync_method },
"audio sync method", "" },
{ "passlogfile", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_EXPERT | OPT_SPEC |
OPT_OUTPUT, { .off = OFFSET(passlogfiles) },
"select two pass log file name prefix", "prefix" },
- { "vstats", OPT_VIDEO | OPT_EXPERT , { &opt_vstats },
+ { "vstats", OPT_VIDEO | OPT_EXPERT , { .func_arg = &opt_vstats },
"dump video coding statistics to file" },
- { "vstats_file", OPT_VIDEO | HAS_ARG | OPT_EXPERT , { opt_vstats_file },
+ { "vstats_file", OPT_VIDEO | HAS_ARG | OPT_EXPERT , { .func_arg = opt_vstats_file },
"dump video coding statistics to file", "file" },
{ "vf", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_video_filters },
"video filters", "filter list" },