av_dict_free(&output_files[i].opts);
}
for(i=0;i<nb_input_files;i++) {
- av_close_input_file(input_files[i].ctx);
+ avformat_close_input(&input_files[i].ctx);
}
for (i = 0; i < nb_input_streams; i++) {
av_freep(&input_streams[i].decoded_frame);
exit (255);
}
- exit(ret); /* not all OS-es handle main() return value */
+ exit(ret);
}
static void assert_avoptions(AVDictionary *m)
ic->flags |= AVFMT_FLAG_NONBLOCK;
ic->interrupt_callback = int_cb;
- /* open the input file with generic libav function */
+ /* open the input file with generic avformat function */
err = avformat_open_input(&ic, filename, file_iformat, &format_opts);
if (err < 0) {
print_error(filename, err);
ret = avformat_find_stream_info(ic, opts);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "%s: could not find codec parameters\n", filename);
- av_close_input_file(ic);
+ avformat_close_input(&ic);
exit_program(1);
}
return 0;
}
-static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const char *filename)
-{
- int i, err;
- AVFormatContext *ic = avformat_alloc_context();
-
- ic->interrupt_callback = int_cb;
- err = avformat_open_input(&ic, filename, NULL, NULL);
- if (err < 0)
- return err;
- /* copy stream format */
- for(i=0;i<ic->nb_streams;i++) {
- AVStream *st;
- OutputStream *ost;
- AVCodec *codec;
-
- codec = avcodec_find_encoder(ic->streams[i]->codec->codec_id);
- ost = new_output_stream(o, s, codec->type);
- st = ost->st;
-
- // FIXME: a more elegant solution is needed
- memcpy(st, ic->streams[i], sizeof(AVStream));
- st->info = av_malloc(sizeof(*st->info));
- memcpy(st->info, ic->streams[i]->info, sizeof(*st->info));
- avcodec_copy_context(st->codec, ic->streams[i]->codec);
-
- if (st->codec->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, codec);
- }
-
- av_close_input_file(ic);
- return 0;
-}
-
static void opt_output_file(void *optctx, const char *filename)
{
OptionsContext *o = optctx;
file_oformat= oc->oformat;
oc->interrupt_callback = int_cb;
- if (!strcmp(file_oformat->name, "ffm") &&
- av_strstart(filename, "http:", NULL)) {
- /* special case for files sent to ffserver: we get the stream
- parameters from ffserver */
- int err = read_ffserver_streams(o, oc, filename);
- if (err < 0) {
- print_error(filename, err);
- exit_program(1);
- }
- } else if (!o->nb_stream_maps) {
+ if (!o->nb_stream_maps) {
/* pick the "best" stream of each type */
#define NEW_STREAM(type, index)\
if (index >= 0) {\
}
if (!(oc->oformat->flags & AVFMT_NOFILE)) {
- /* test if it already exists to avoid loosing precious files */
+ /* test if it already exists to avoid losing precious files */
assert_file_overwrite(filename);
/* open the file */
{ "c", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "codec name", "codec" },
{ "codec", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "codec name", "codec" },
{ "pre", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(presets)}, "preset name", "preset" },
- { "map", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map}, "set input stream mapping", "file.stream[:syncfile.syncstream]" },
+ { "map", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map}, "set input stream mapping", "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
{ "map_metadata", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map_metadata}, "set metadata information of outfile from infile",
"outfile[,metadata]:infile[,metadata]" },
{ "map_chapters", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(chapters_input_file)}, "set chapters mapping", "input_file_index" },