mirror of
https://github.com/mpv-player/mpv
synced 2025-01-13 18:45:25 +00:00
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.)
This commit is contained in:
parent
74ab902dea
commit
fdbf437055
@ -186,6 +186,16 @@
|
||||
name to force it, this will skip some checks! Give the demuxer name as
|
||||
printed by ``--audio-demuxer=help``. ``--audio-demuxer=audio`` forces MP3.
|
||||
|
||||
--audio-display=<no|attachment>
|
||||
Setting this option to ``attachment`` (default) will display image
|
||||
attachments when playing audio files. It will display the first image
|
||||
found, and additional images are available as video streams.
|
||||
|
||||
Setting this option to ``no`` disables display of video entirely when
|
||||
playing audio files.
|
||||
|
||||
This option has no influence on files with normal video tracks.
|
||||
|
||||
--audiofile=<filename>
|
||||
Play audio from an external file (WAV, MP3 or Ogg Vorbis) while viewing a
|
||||
movie.
|
||||
|
@ -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},
|
||||
|
@ -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,
|
||||
|
@ -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).
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -438,6 +438,8 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i)
|
||||
priv->vstreams[priv->video_streams] = i;
|
||||
sh_video->libav_codec_id = codec->codec_id;
|
||||
sh_video->gsh->lavf_codec_tag = lavf_codec_tag;
|
||||
if (st->disposition & AV_DISPOSITION_ATTACHED_PIC)
|
||||
sh_video->gsh->attached_picture = true;
|
||||
bih = calloc(sizeof(*bih) + codec->extradata_size, 1);
|
||||
|
||||
if (codec->codec_id == CODEC_ID_RAWVIDEO) {
|
||||
|
@ -58,7 +58,8 @@ struct sh_stream {
|
||||
int lavf_codec_tag;
|
||||
|
||||
char *title;
|
||||
bool default_track;
|
||||
bool default_track; // container default track flag
|
||||
bool attached_picture; // stream is a picture (such as album art)
|
||||
|
||||
// shouldn't exist type of stuff
|
||||
struct MPOpts *opts;
|
||||
|
Loading…
Reference in New Issue
Block a user