diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 974d1c108f..2fb0bc8ffa 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1492,6 +1492,10 @@ Allow input streams with unknown type to be copied instead of failing if copying such streams is attempted. @item -map_channel [@var{input_file_id}.@var{stream_specifier}.@var{channel_id}|-1][?][:@var{output_file_id}.@var{stream_specifier}] +This option is deprecated and will be removed. It can be replaced by the +@var{pan} filter. In some cases it may be easier to use some combination of the +@var{channelsplit}, @var{channelmap}, or @var{amerge} filters. + Map an audio channel from a given input to an output. If @var{output_file_id}.@var{stream_specifier} is not set, the audio channel will be mapped on all the audio streams. diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index c1ce017d80..30df93de2c 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -578,8 +578,10 @@ static void ffmpeg_cleanup(int ret) av_freep(&ost->avfilter); av_freep(&ost->logfile_prefix); +#if FFMPEG_OPT_MAP_CHANNEL av_freep(&ost->audio_channels_map); ost->audio_channels_mapped = 0; +#endif av_dict_free(&ost->sws_dict); av_dict_free(&ost->swr_opts); diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 66a49a0cb7..6417db03bd 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -51,6 +51,7 @@ // deprecated features #define FFMPEG_OPT_PSNR 1 +#define FFMPEG_OPT_MAP_CHANNEL 1 enum VideoSyncMethod { VSYNC_AUTO = -1, @@ -85,10 +86,12 @@ typedef struct StreamMap { char *linklabel; /* name of an output link, for mapping lavfi outputs */ } StreamMap; +#if FFMPEG_OPT_MAP_CHANNEL typedef struct { int file_idx, stream_idx, channel_idx; // input int ofile_idx, ostream_idx; // output } AudioChannelMap; +#endif typedef struct OptionsContext { OptionGroup *g; @@ -141,8 +144,10 @@ typedef struct OptionsContext { /* output options */ StreamMap *stream_maps; int nb_stream_maps; +#if FFMPEG_OPT_MAP_CHANNEL AudioChannelMap *audio_channel_maps; /* one info entry per -map_channel */ int nb_audio_channel_maps; /* number of (valid) -map_channel settings */ +#endif int metadata_global_manual; int metadata_streams_manual; int metadata_chapters_manual; @@ -516,8 +521,10 @@ typedef struct OutputStream { int dropped_keyframe; /* audio only */ +#if FFMPEG_OPT_MAP_CHANNEL int *audio_channels_map; /* list of the channels id to pick from the source stream */ int audio_channels_mapped; /* number of channels in audio_channels_map */ +#endif char *logfile_prefix; FILE *logfile; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 6807bf384a..5d00bfe056 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -560,6 +560,7 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, pad_idx = 0; \ } while (0) av_bprint_init(&args, 0, AV_BPRINT_SIZE_UNLIMITED); +#if FFMPEG_OPT_MAP_CHANNEL if (ost->audio_channels_mapped) { AVChannelLayout mapped_layout = { 0 }; int i; @@ -572,6 +573,7 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, AUTO_INSERT_FILTER("-map_channel", "pan", args.str); av_bprint_clear(&args); } +#endif if (codec->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) av_channel_layout_default(&codec->ch_layout, codec->ch_layout.nb_channels); diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 444392fd45..e6f2fb597a 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -219,7 +219,9 @@ static void uninit_options(OptionsContext *o) for (i = 0; i < o->nb_stream_maps; i++) av_freep(&o->stream_maps[i].linklabel); av_freep(&o->stream_maps); +#if FFMPEG_OPT_MAP_CHANNEL av_freep(&o->audio_channel_maps); +#endif av_freep(&o->streamid_map); av_freep(&o->attachments); } @@ -534,6 +536,7 @@ static int opt_attach(void *optctx, const char *opt, const char *arg) return 0; } +#if FFMPEG_OPT_MAP_CHANNEL static int opt_map_channel(void *optctx, const char *opt, const char *arg) { OptionsContext *o = optctx; @@ -542,6 +545,12 @@ static int opt_map_channel(void *optctx, const char *opt, const char *arg) AudioChannelMap *m; char *allow_unused; char *mapchan; + + av_log(NULL, AV_LOG_WARNING, + "The -%s option is deprecated and will be removed. " + "It can be replaced by the 'pan' filter, or in some cases by " + "combinations of 'channelsplit', 'channelmap', 'amerge' filters.\n", opt); + mapchan = av_strdup(arg); if (!mapchan) return AVERROR(ENOMEM); @@ -610,6 +619,7 @@ static int opt_map_channel(void *optctx, const char *opt, const char *arg) av_free(mapchan); return 0; } +#endif static int opt_sdp_file(void *optctx, const char *opt, const char *arg) { @@ -2061,7 +2071,6 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, int source_index) { - int n; AVStream *st; OutputStream *ost; @@ -2121,8 +2130,9 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, in if (!ost->avfilter) exit_program(1); +#if FFMPEG_OPT_MAP_CHANNEL /* check for channel mapping for this audio stream */ - for (n = 0; n < o->nb_audio_channel_maps; n++) { + for (int n = 0; n < o->nb_audio_channel_maps; n++) { AudioChannelMap *map = &o->audio_channel_maps[n]; if ((map->ofile_idx == -1 || ost->file_index == map->ofile_idx) && (map->ostream_idx == -1 || ost->st->index == map->ostream_idx)) { @@ -2149,6 +2159,7 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, in } } } +#endif } if (ost->stream_copy) @@ -3759,8 +3770,10 @@ const OptionDef options[] = { OPT_OUTPUT, { .func_arg = opt_map }, "set input stream mapping", "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" }, +#if FFMPEG_OPT_MAP_CHANNEL { "map_channel", HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_map_channel }, - "map an audio channel from one stream to another", "file.stream.channel[:syncfile.syncstream]" }, + "map an audio channel from one stream to another (deprecated)", "file.stream.channel[:syncfile.syncstream]" }, +#endif { "map_metadata", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(metadata_map) }, "set metadata information of outfile from infile",