From fdbf43705581ee676d3e1d22210def3e21ce8fb3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 10 Dec 2012 18:52:06 +0100 Subject: core: allow disabling display of "album art" in audio files ffmpeg pretends that image attachments (such as contained in ID3v2 metadata) are video streams. It injects the attached pictures as packets into the packet stream received with av_read_frame(). Add the --audio-display option to allow configuring whether attached pictures should be displayed. The default behavior doesn't change (images are displayed). Identify video streams, that are actually image attachments, with "[P]" in the terminal output. Modify the default stream selection such that real video streams are preferred over attached pictures. (This is just for robustness; I do not know of any samples where images are added before actual video streams and could lead to bad default stream selection with the old code.) --- core/cfg-mplayer.h | 3 +++ core/defaultopts.c | 1 + core/mp_core.h | 1 + core/mplayer.c | 17 ++++++++++++----- core/options.h | 1 + 5 files changed, 18 insertions(+), 5 deletions(-) (limited to 'core') diff --git a/core/cfg-mplayer.h b/core/cfg-mplayer.h index 6534672223..762c13a2bb 100644 --- a/core/cfg-mplayer.h +++ b/core/cfg-mplayer.h @@ -394,6 +394,9 @@ const m_option_t common_opts[] = { OPT_STRINGLIST("alang", audio_lang, 0), OPT_STRINGLIST("slang", sub_lang, 0), + OPT_CHOICE("audio-display", audio_display, 0, + ({"no", 0}, {"attachment", 1})), + OPT_STRING("quvi-format", quvi_format, 0), { "rawaudio", (void *)&demux_rawaudio_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, diff --git a/core/defaultopts.c b/core/defaultopts.c index 9f746b3dc1..4338e10b0a 100644 --- a/core/defaultopts.c +++ b/core/defaultopts.c @@ -44,6 +44,7 @@ void set_default_mplayer_options(struct MPOpts *opts) .audio_id = -1, .video_id = -1, .sub_id = -1, + .audio_display = 1, .sub_visibility = 1, .extension_parsing = 1, .audio_output_channels = 2, diff --git a/core/mp_core.h b/core/mp_core.h index 92803d2dd0..5a7926dee9 100644 --- a/core/mp_core.h +++ b/core/mp_core.h @@ -89,6 +89,7 @@ struct track { char *title; bool default_track; + bool attached_picture; char *lang; // If this track is from an external file (e.g. subtitle file). diff --git a/core/mplayer.c b/core/mplayer.c index 99fd4b46ed..5dc35479ba 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -320,6 +320,8 @@ static void print_stream(struct MPContext *mpctx, struct track *t, int id) mp_msg(MSGT_CPLAYER, MSGL_INFO, " --%s=%s", langopt, t->lang); if (t->default_track) mp_msg(MSGT_CPLAYER, MSGL_INFO, " (*)"); + if (t->attached_picture) + mp_msg(MSGT_CPLAYER, MSGL_INFO, " [P]"); if (t->title) mp_msg(MSGT_CPLAYER, MSGL_INFO, " '%s'", t->title); mp_msg(MSGT_CPLAYER, MSGL_INFO, " ("); @@ -914,6 +916,7 @@ static struct track *add_stream_track(struct MPContext *mpctx, .demuxer_id = stream->demuxer_id, .title = stream->title, .default_track = stream->default_track, + .attached_picture = stream->attached_picture, .lang = stream->common_header->lang, .under_timeline = under_timeline, .demuxer = stream->demuxer, @@ -3592,14 +3595,16 @@ static bool compare_track(struct track *t1, struct track *t2, char **langs) return l1 > l2; if (t1->default_track != t2->default_track) return t1->default_track; + if (t1->attached_picture != t2->attached_picture) + return !t1->attached_picture; return t1->user_tid <= t2->user_tid; } static struct track *select_track(struct MPContext *mpctx, - enum stream_type type, int tid, char **langs, - bool select_fallback) + enum stream_type type, int tid, char **langs) { if (tid == -2) return NULL; + bool select_fallback = type == STREAM_VIDEO || type == STREAM_AUDIO; struct track *pick = NULL; for (int n = 0; n < mpctx->num_tracks; n++) { struct track *track = mpctx->tracks[n]; @@ -3613,6 +3618,8 @@ static struct track *select_track(struct MPContext *mpctx, if (pick && !select_fallback && !pick->is_external && !match_lang(langs, pick->lang) && !pick->default_track) pick = NULL; + if (pick && pick->attached_picture && !mpctx->opts.audio_display) + pick = NULL; return pick; } @@ -3990,13 +3997,13 @@ goto_enable_cache: ; check_previous_track_selection(mpctx); mpctx->current_track[STREAM_VIDEO] = - select_track(mpctx, STREAM_VIDEO, mpctx->opts.video_id, NULL, true); + select_track(mpctx, STREAM_VIDEO, mpctx->opts.video_id, NULL); mpctx->current_track[STREAM_AUDIO] = select_track(mpctx, STREAM_AUDIO, mpctx->opts.audio_id, - mpctx->opts.audio_lang, true); + mpctx->opts.audio_lang); mpctx->current_track[STREAM_SUB] = select_track(mpctx, STREAM_SUB, mpctx->opts.sub_id, - mpctx->opts.sub_lang, false); + mpctx->opts.sub_lang); demux_info_print(mpctx->master_demuxer); print_file_properties(mpctx, mpctx->filename); diff --git a/core/options.h b/core/options.h index f6e2a169f0..da4449cb11 100644 --- a/core/options.h +++ b/core/options.h @@ -85,6 +85,7 @@ typedef struct MPOpts { int sub_id; char **audio_lang; char **sub_lang; + int audio_display; int sub_visibility; char *quvi_format; -- cgit v1.2.3