X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffmpeg_opt.c;h=6862456c27082f66cbef55aa1642b181c9ee2bc8;hb=89d4d7d759a59e8535b267b7f5af757f731da712;hp=29d0bed0bc073abd9da55f040e1ac99fd503e896;hpb=6b449a12906c494f3530d4fa282ec6c4c6aa687e;p=ffmpeg diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 29d0bed0bc0..6862456c270 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -119,6 +119,8 @@ int qp_hist = 0; int stdin_interaction = 1; int frame_bits_per_raw_sample = 0; float max_error_rate = 2.0/3; +int filter_nbthreads = 0; +int filter_complex_nbthreads = 0; static int intra_only = 0; @@ -1971,6 +1973,7 @@ static void init_output_filter(OutputFilter *ofilter, OptionsContext *o, 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, " @@ -2043,7 +2046,7 @@ static int open_output_file(OptionsContext *o, const char *filename) InputStream *ist; AVDictionary *unused_opts = NULL; AVDictionaryEntry *e = NULL; - + int format_flags = 0; if (o->stop_time != INT64_MAX && o->recording_time != INT64_MAX) { o->stop_time = INT64_MAX; @@ -2089,6 +2092,12 @@ static int open_output_file(OptionsContext *o, const char *filename) file_oformat= oc->oformat; oc->interrupt_callback = int_cb; + e = av_dict_get(o->g->format_opts, "fflags", NULL, 0); + if (e) { + const AVOption *o = av_opt_find(oc, "fflags", NULL, 0, 0); + av_opt_eval_flags(oc, o, e->value, &format_flags); + } + /* create streams for all unlabeled output pads */ for (i = 0; i < nb_filtergraphs; i++) { FilterGraph *fg = filtergraphs[i]; @@ -2109,6 +2118,7 @@ static int open_output_file(OptionsContext *o, const char *filename) /* ffserver seeking with date=... needs a date reference */ if (!strcmp(file_oformat->name, "ffm") && + !(format_flags & AVFMT_FLAG_BITEXACT) && av_strstart(filename, "http:", NULL)) { int err = parse_option(o, "metadata", "creation_time=now", options); if (err < 0) { @@ -2415,6 +2425,67 @@ loop_end: } } } + + /* 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 */ @@ -3124,8 +3195,8 @@ enum OptGroup { }; static const OptionGroupDef groups[] = { - [GROUP_OUTFILE] = { "output file", NULL, OPT_OUTPUT }, - [GROUP_INFILE] = { "input file", "i", OPT_INPUT }, + [GROUP_OUTFILE] = { "output url", NULL, OPT_OUTPUT }, + [GROUP_INFILE] = { "input url", "i", OPT_INPUT }, }; static int open_files(OptionGroupList *l, const char *inout,