exit_program(1);
}
st = input_files[m->file_idx]->ctx->streams[m->stream_idx];
- if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO) {
+ if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) {
av_log(NULL, AV_LOG_FATAL, "mapchan: stream #%d.%d is not an audio stream.\n",
m->file_idx, m->stream_idx);
exit_program(1);
}
- if (m->channel_idx < 0 || m->channel_idx >= st->codec->channels) {
+ if (m->channel_idx < 0 || m->channel_idx >= st->codecpar->channels) {
av_log(NULL, AV_LOG_FATAL, "mapchan: invalid audio channel #%d.%d.%d\n",
m->file_idx, m->stream_idx, m->channel_idx);
exit_program(1);
MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st);
if (codec_name) {
- AVCodec *codec = find_codec_or_die(codec_name, st->codec->codec_type, 0);
- st->codec->codec_id = codec->id;
+ AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type, 0);
+ st->codecpar->codec_id = codec->id;
return codec;
} else
- return avcodec_find_decoder(st->codec->codec_id);
+ return avcodec_find_decoder(st->codecpar->codec_id);
}
/* Add all the streams from the given input file to the global
for (i = 0; i < ic->nb_streams; i++) {
AVStream *st = ic->streams[i];
- AVCodecContext *dec = st->codec;
+ AVCodecParameters *par = st->codecpar;
InputStream *ist = av_mallocz(sizeof(*ist));
char *framerate = NULL, *hwaccel = NULL, *hwaccel_device = NULL;
char *hwaccel_output_format = NULL;
char *codec_tag = NULL;
char *next;
char *discard_str = NULL;
- const AVOption *discard_opt = av_opt_find(dec, "skip_frame", NULL, 0, 0);
+ const AVClass *cc = avcodec_get_class();
+ const AVOption *discard_opt = av_opt_find(&cc, "skip_frame", NULL, 0, 0);
if (!ist)
exit_program(1);
uint32_t tag = strtol(codec_tag, &next, 0);
if (*next)
tag = AV_RL32(codec_tag);
- st->codec->codec_tag = tag;
+ st->codecpar->codec_tag = tag;
}
ist->dec = choose_decoder(o, ic, st);
- ist->decoder_opts = filter_codec_opts(o->g->codec_opts, ist->st->codec->codec_id, ic, st, ist->dec);
+ ist->decoder_opts = filter_codec_opts(o->g->codec_opts, ist->st->codecpar->codec_id, ic, st, ist->dec);
ist->reinit_filters = -1;
MATCH_PER_STREAM_OPT(reinit_filters, i, ist->reinit_filters, ic, st);
MATCH_PER_STREAM_OPT(discard, str, discard_str, ic, st);
ist->user_set_discard = AVDISCARD_NONE;
- if (discard_str && av_opt_eval_int(dec, discard_opt, discard_str, &ist->user_set_discard) < 0) {
+ if (discard_str && av_opt_eval_int(&cc, discard_opt, discard_str, &ist->user_set_discard) < 0) {
av_log(NULL, AV_LOG_ERROR, "Error parsing discard %s.\n",
discard_str);
exit_program(1);
exit_program(1);
}
- ret = avcodec_copy_context(ist->dec_ctx, dec);
+ ret = avcodec_parameters_to_context(ist->dec_ctx, par);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error initializing the decoder context.\n");
exit_program(1);
}
- switch (dec->codec_type) {
+ switch (par->codec_type) {
case AVMEDIA_TYPE_VIDEO:
if(!ist->dec)
- ist->dec = avcodec_find_decoder(dec->codec_id);
+ ist->dec = avcodec_find_decoder(par->codec_id);
#if FF_API_EMU_EDGE
- if (av_codec_get_lowres(dec)) {
- dec->flags |= CODEC_FLAG_EMU_EDGE;
+ if (av_codec_get_lowres(st->codec)) {
+ av_codec_set_lowres(ist->dec_ctx, av_codec_get_lowres(st->codec));
+ ist->dec_ctx->width = st->codec->width;
+ ist->dec_ctx->height = st->codec->height;
+ ist->dec_ctx->coded_width = st->codec->coded_width;
+ ist->dec_ctx->coded_height = st->codec->coded_height;
+ ist->dec_ctx->flags |= CODEC_FLAG_EMU_EDGE;
}
#endif
+ // avformat_find_stream_info() doesn't set this for us anymore.
+ ist->dec_ctx->framerate = st->avg_frame_rate;
+
ist->resample_height = ist->dec_ctx->height;
ist->resample_width = ist->dec_ctx->width;
ist->resample_pix_fmt = ist->dec_ctx->pix_fmt;
case AVMEDIA_TYPE_SUBTITLE: {
char *canvas_size = NULL;
if(!ist->dec)
- ist->dec = avcodec_find_decoder(dec->codec_id);
+ ist->dec = avcodec_find_decoder(par->codec_id);
MATCH_PER_STREAM_OPT(fix_sub_duration, i, ist->fix_sub_duration, ic, st);
MATCH_PER_STREAM_OPT(canvas_sizes, str, canvas_size, ic, st);
if (canvas_size &&
default:
abort();
}
+
+ ret = avcodec_parameters_from_context(par, ist->dec_ctx);
+ if (ret < 0) {
+ av_log(NULL, AV_LOG_ERROR, "Error initializing the decoder context.\n");
+ exit_program(1);
+ }
}
}
AVIOContext *out = NULL;
AVDictionaryEntry *e;
- if (!st->codec->extradata_size) {
+ if (!st->codecpar->extradata_size) {
av_log(NULL, AV_LOG_WARNING, "No extradata to dump in stream #%d:%d.\n",
nb_input_files - 1, st->index);
return;
exit_program(1);
}
- avio_write(out, st->codec->extradata, st->codec->extradata_size);
+ avio_write(out, st->codecpar->extradata, st->codecpar->extradata_size);
avio_flush(out);
avio_close(out);
}
if (!(ic->iformat->flags & AVFMT_SEEK_TO_PTS)) {
int dts_heuristic = 0;
for (i=0; i<ic->nb_streams; i++) {
- AVCodecContext *avctx = ic->streams[i]->codec;
- if (avctx->has_b_frames)
+ const AVCodecParameters *par = ic->streams[i]->codecpar;
+ if (par->video_delay)
dts_heuristic = 1;
}
if (dts_heuristic) {
static int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost)
{
- enum AVMediaType type = ost->st->codec->codec_type;
+ enum AVMediaType type = ost->st->codecpar->codec_type;
char *codec_name = NULL;
if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO || type == AVMEDIA_TYPE_SUBTITLE) {
MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st);
if (!codec_name) {
- ost->st->codec->codec_id = av_guess_codec(s->oformat, NULL, s->filename,
- NULL, ost->st->codec->codec_type);
- ost->enc = avcodec_find_encoder(ost->st->codec->codec_id);
+ ost->st->codecpar->codec_id = av_guess_codec(s->oformat, NULL, s->filename,
+ NULL, ost->st->codecpar->codec_type);
+ ost->enc = avcodec_find_encoder(ost->st->codecpar->codec_id);
if (!ost->enc) {
av_log(NULL, AV_LOG_FATAL, "Automatic encoder selection failed for "
"output stream #%d:%d. Default encoder for format %s (codec %s) is "
"probably disabled. Please choose an encoder manually.\n",
ost->file_index, ost->index, s->oformat->name,
- avcodec_get_name(ost->st->codec->codec_id));
+ avcodec_get_name(ost->st->codecpar->codec_id));
return AVERROR_ENCODER_NOT_FOUND;
}
} else if (!strcmp(codec_name, "copy"))
ost->stream_copy = 1;
else {
- ost->enc = find_codec_or_die(codec_name, ost->st->codec->codec_type, 1);
- ost->st->codec->codec_id = ost->enc->id;
+ ost->enc = find_codec_or_die(codec_name, ost->st->codecpar->codec_type, 1);
+ ost->st->codecpar->codec_id = ost->enc->id;
}
ost->encoding_needed = !ost->stream_copy;
} else {
OutputStream *ost;
AVStream *st = avformat_new_stream(oc, NULL);
int idx = oc->nb_streams - 1, ret = 0;
- char *bsf = NULL, *next, *codec_tag = NULL;
- AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
+ const char *bsfs = NULL;
+ char *next, *codec_tag = NULL;
double qscale = -1;
int i;
ost->file_index = nb_output_files - 1;
ost->index = idx;
ost->st = st;
- st->codec->codec_type = type;
+ st->codecpar->codec_type = type;
ret = choose_encoder(o, oc, ost);
if (ret < 0) {
}
ost->enc_ctx->codec_type = type;
+ ost->ref_par = avcodec_parameters_alloc();
+ if (!ost->ref_par) {
+ av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding parameters.\n");
+ exit_program(1);
+ }
+
if (ost->enc) {
AVIOContext *s = NULL;
char *buf = NULL, *arg = NULL, *preset = NULL;
ost->copy_prior_start = -1;
MATCH_PER_STREAM_OPT(copy_prior_start, i, ost->copy_prior_start, oc ,st);
- MATCH_PER_STREAM_OPT(bitstream_filters, str, bsf, oc, st);
- while (bsf) {
- char *arg = NULL;
- if (next = strchr(bsf, ','))
- *next++ = 0;
- if (arg = strchr(bsf, '='))
- *arg++ = 0;
- if (!(bsfc = av_bitstream_filter_init(bsf))) {
- av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\n", bsf);
+ MATCH_PER_STREAM_OPT(bitstream_filters, str, bsfs, oc, st);
+ while (bsfs && *bsfs) {
+ const AVBitStreamFilter *filter;
+ char *bsf, *bsf_options_str, *bsf_name;
+
+ bsf = av_get_token(&bsfs, ",");
+ if (!bsf)
+ exit_program(1);
+ bsf_name = av_strtok(bsf, "=", &bsf_options_str);
+ if (!bsf_name)
+ exit_program(1);
+
+ filter = av_bsf_get_by_name(bsf_name);
+ if (!filter) {
+ av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\n", bsf_name);
exit_program(1);
}
- if (bsfc_prev)
- bsfc_prev->next = bsfc;
- else
- ost->bitstream_filters = bsfc;
- if (arg)
- if (!(bsfc->args = av_strdup(arg))) {
- av_log(NULL, AV_LOG_FATAL, "Bitstream filter memory allocation failed\n");
+
+ 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 bitstream filter context\n");
+ exit_program(1);
+ }
+
+ ost->nb_bitstream_filters++;
+
+ if (bsf_options_str && filter->priv_class) {
+ const AVOption *opt = av_opt_next(ost->bsf_ctx[ost->nb_bitstream_filters-1]->priv_data, NULL);
+ const char * shorthand[2] = {NULL};
+
+ if (opt)
+ shorthand[0] = opt->name;
+
+ ret = av_opt_set_from_string(ost->bsf_ctx[ost->nb_bitstream_filters-1]->priv_data, bsf_options_str, shorthand, "=", ":");
+ 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);
- bsfc_prev = bsfc;
- bsf = next;
+ if (*bsfs)
+ bsfs++;
+ }
+ if (ost->nb_bitstream_filters) {
+ ost->bsf_extradata_updated = av_mallocz_array(ost->nb_bitstream_filters, sizeof(*ost->bsf_extradata_updated));
+ if (!ost->bsf_extradata_updated) {
+ av_log(NULL, AV_LOG_FATAL, "Bitstream filter memory allocation failed\n");
+ exit_program(1);
+ }
}
MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, oc, st);
uint32_t tag = strtol(codec_tag, &next, 0);
if (*next)
tag = AV_RL32(codec_tag);
- ost->st->codec->codec_tag =
+ ost->st->codecpar->codec_tag =
ost->enc_ctx->codec_tag = tag;
}
MATCH_PER_STREAM_OPT(disposition, str, ost->disposition, oc, st);
ost->disposition = av_strdup(ost->disposition);
+ ost->max_muxing_queue_size = 128;
+ MATCH_PER_STREAM_OPT(max_muxing_queue_size, i, ost->max_muxing_queue_size, oc, st);
+ ost->max_muxing_queue_size *= sizeof(AVPacket);
+
if (oc->oformat->flags & AVFMT_GLOBALHEADER)
ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
}
ost->last_mux_dts = AV_NOPTS_VALUE;
+ ost->muxing_queue = av_fifo_alloc(8 * sizeof(AVPacket));
+ if (!ost->muxing_queue)
+ exit_program(1);
+
return ost;
}
else if (ost->filters)
return av_strdup(ost->filters);
- return av_strdup(st->codec->codec_type == AVMEDIA_TYPE_VIDEO ?
+ return av_strdup(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ?
"null" : "anull");
}
AVCodec *codec;
const char *enc_config;
- codec = avcodec_find_encoder(ic->streams[i]->codec->codec_id);
+ codec = avcodec_find_encoder(ic->streams[i]->codecpar->codec_id);
if (!codec) {
- av_log(s, AV_LOG_ERROR, "no encoder found for codec id %i\n", ic->streams[i]->codec->codec_id);
+ av_log(s, AV_LOG_ERROR, "no encoder found for codec id %i\n", ic->streams[i]->codecpar->codec_id);
return AVERROR(EINVAL);
}
if (codec->type == AVMEDIA_TYPE_AUDIO)
av_dict_free(&opts);
}
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && !ost->stream_copy)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && !ost->stream_copy)
choose_sample_fmt(st, codec);
- else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && !ost->stream_copy)
- choose_pixel_fmt(st, st->codec, codec, st->codec->pix_fmt);
+ else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && !ost->stream_copy)
+ choose_pixel_fmt(st, st->codec, codec, st->codecpar->format);
avcodec_copy_context(ost->enc_ctx, st->codec);
if (enc_config)
av_dict_parse_string(&ost->encoder_opts, enc_config, "=", ",", 0);
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, "
static int configure_complex_filters(void)
{
- int i, ret = 0;
+ int i, j, ret = 0;
+
+ for (i = 0; i < nb_filtergraphs; i++) {
+ FilterGraph *fg = filtergraphs[i];
+
+ if (filtergraph_is_simple(fg))
+ continue;
- for (i = 0; i < nb_filtergraphs; i++)
- if (!filtergraph_is_simple(filtergraphs[i]) &&
- (ret = configure_filtergraph(filtergraphs[i])) < 0)
+ for (j = 0; j < fg->nb_inputs; j++) {
+ ret = ifilter_parameters_from_decoder(fg->inputs[j],
+ fg->inputs[j]->ist->dec_ctx);
+ if (ret < 0) {
+ av_log(NULL, AV_LOG_ERROR,
+ "Error initializing filtergraph %d input %d\n", i, j);
+ return ret;
+ }
+ }
+
+ ret = configure_filtergraph(filtergraphs[i]);
+ if (ret < 0)
return ret;
+ }
return 0;
}
ost = output_streams[j];
for (i = 0; i < nb_input_streams; i++) {
ist = input_streams[i];
- if(ist->st->codec->codec_type == ost->st->codec->codec_type){
+ if(ist->st->codecpar->codec_type == ost->st->codecpar->codec_type){
ost->sync_ist= ist;
ost->source_index= i;
- if(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) ost->avfilter = av_strdup("anull");
- if(ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) ost->avfilter = av_strdup("null");
+ if(ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) ost->avfilter = av_strdup("anull");
+ if(ost->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) ost->avfilter = av_strdup("null");
ist->discard = 0;
ist->st->discard = ist->user_set_discard;
break;
}
}
if(!ost->sync_ist){
- av_log(NULL, AV_LOG_FATAL, "Missing %s stream which is required by this ffm\n", av_get_media_type_string(ost->st->codec->codec_type));
+ av_log(NULL, AV_LOG_FATAL, "Missing %s stream which is required by this ffm\n", av_get_media_type_string(ost->st->codecpar->codec_type));
exit_program(1);
}
}
for (i = 0; i < nb_input_streams; i++) {
int new_area;
ist = input_streams[i];
- new_area = ist->st->codec->width * ist->st->codec->height + 100000000*!!ist->st->codec_info_nb_frames;
+ new_area = ist->st->codecpar->width * ist->st->codecpar->height + 100000000*!!ist->st->codec_info_nb_frames;
if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
new_area = 1;
- if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
+ if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
new_area > area) {
if((qcr==MKTAG('A', 'P', 'I', 'C')) && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
continue;
for (i = 0; i < nb_input_streams; i++) {
int score;
ist = input_streams[i];
- score = ist->st->codec->channels + 100000000*!!ist->st->codec_info_nb_frames;
- if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
+ score = ist->st->codecpar->channels + 100000000*!!ist->st->codec_info_nb_frames;
+ if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
score > best_score) {
best_score = score;
idx = i;
MATCH_PER_TYPE_OPT(codec_names, str, subtitle_codec_name, oc, "s");
if (!o->subtitle_disable && (avcodec_find_encoder(oc->oformat->subtitle_codec) || subtitle_codec_name)) {
for (i = 0; i < nb_input_streams; i++)
- if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+ if (input_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
AVCodecDescriptor const *input_descriptor =
- avcodec_descriptor_get(input_streams[i]->st->codec->codec_id);
+ avcodec_descriptor_get(input_streams[i]->st->codecpar->codec_id);
AVCodecDescriptor const *output_descriptor = NULL;
AVCodec const *output_codec =
avcodec_find_encoder(oc->oformat->subtitle_codec);
if (!o->data_disable ) {
enum AVCodecID codec_id = av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_DATA);
for (i = 0; codec_id != AV_CODEC_ID_NONE && i < nb_input_streams; i++) {
- if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_DATA
- && input_streams[i]->st->codec->codec_id == codec_id )
+ if (input_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_DATA
+ && input_streams[i]->st->codecpar->codec_id == codec_id )
new_data_stream(o, oc, i);
}
}
int src_idx = input_files[map->file_index]->ist_index + map->stream_index;
ist = input_streams[input_files[map->file_index]->ist_index + map->stream_index];
- if(o->subtitle_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE)
+ if(o->subtitle_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)
continue;
- if(o-> audio_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+ if(o-> audio_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
continue;
- if(o-> video_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+ if(o-> video_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
continue;
- if(o-> data_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_DATA)
+ if(o-> data_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_DATA)
continue;
ost = NULL;
- switch (ist->st->codec->codec_type) {
+ switch (ist->st->codecpar->codec_type) {
case AVMEDIA_TYPE_VIDEO: ost = new_video_stream (o, oc, src_idx); break;
case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream (o, oc, src_idx); break;
case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream (o, oc, src_idx); break;
avio_read(pb, attachment, len);
ost = new_attachment_stream(o, oc, -1);
+ ost->stream_copy = 0;
ost->attachment_filename = o->attachments[i];
- ost->st->codec->extradata = attachment;
- ost->st->codec->extradata_size = len;
+ ost->st->codecpar->extradata = attachment;
+ ost->st->codecpar->extradata_size = len;
p = strrchr(o->attachments[i], '/');
av_dict_set(&ost->st->metadata, "filename", (p && *p) ? p + 1 : o->attachments[i], AV_DICT_DONT_OVERWRITE);
avio_closep(&pb);
}
+#if FF_API_LAVF_AVCTX
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 (av_opt_set(ost->st->codec, "flags", e->value, 0) < 0)
exit_program(1);
}
+#endif
if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) {
av_dump_format(oc, nb_output_files - 1, oc->filename, 1);
InputStream *ist = input_streams[ost->source_index];
ist->decoding_needed |= DECODING_FOR_OST;
- if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
- ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (ost->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
+ ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
err = init_simple_filtergraph(ist, ost);
if (err < 0) {
av_log(NULL, AV_LOG_ERROR,
}
}
}
+
+ /* 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 */
int i, j, fr;
for (j = 0; j < nb_input_files; j++) {
for (i = 0; i < input_files[j]->nb_streams; i++) {
- AVCodecContext *c = input_files[j]->ctx->streams[i]->codec;
- if (c->codec_type != AVMEDIA_TYPE_VIDEO ||
- !c->time_base.num)
+ AVStream *st = input_files[j]->ctx->streams[i];
+ if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
continue;
- fr = c->time_base.den * 1000 / c->time_base.num;
+ fr = st->time_base.den * 1000 / st->time_base.num;
if (fr == 25000) {
norm = PAL;
break;
goto fail;
}
+ /* configure terminal and setup signal handlers */
+ term_init();
+
/* open input files */
ret = open_files(&octx.groups[GROUP_INFILE], "input", open_input_file);
if (ret < 0) {
"set profile", "profile" },
{ "filter", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(filters) },
"set stream filtergraph", "filter_graph" },
+ { "filter_threads", HAS_ARG | OPT_INT, { &filter_nbthreads },
+ "number of non-complex filter threads" },
{ "filter_script", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(filter_scripts) },
"read stream filtergraph description from a file", "filename" },
{ "reinit_filter", HAS_ARG | OPT_INT | OPT_SPEC | OPT_INPUT, { .off = OFFSET(reinit_filters) },
"reinit filtergraph on input parameter changes", "" },
{ "filter_complex", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex },
"create a complex filtergraph", "graph_description" },
+ { "filter_complex_threads", HAS_ARG | OPT_INT, { &filter_complex_nbthreads },
+ "number of threads for -filter_complex" },
{ "lavfi", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex },
"create a complex filtergraph", "graph_description" },
{ "filter_complex_script", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex_script },
"set the subtitle options to the indicated preset", "preset" },
{ "fpre", HAS_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_preset },
"set options from indicated preset file", "filename" },
+
+ { "max_muxing_queue_size", HAS_ARG | OPT_INT | OPT_SPEC | OPT_EXPERT | OPT_OUTPUT, { .off = OFFSET(max_muxing_queue_size) },
+ "maximum number of packets that can be buffered while waiting for all streams to initialize", "packets" },
+
/* data codec support */
{ "dcodec", HAS_ARG | OPT_DATA | OPT_PERFILE | OPT_EXPERT | OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_data_codec },
"force data codec ('copy' to copy stream)", "codec" },