mirror of https://github.com/mpv-player/mpv
player: add track-list/N/image sub-property
This exposes whether a video track is detected as an image, which is useful for profile conditions, property expansion and lavfi-complex. The lavf demuxer sets image to true when the existing check detects an image. When the lavf demuxer fails, the mf one guesses if the file is an image by its extension, so sh->image is set to true when the mf demuxer succeds and there's only one file. The mkv demuxer just sets image to true for any attached picture. The timeline demuxer just copies the value of image from source to destination. This sets image to true for attached pictures, standalone images and images added with !new_stream in EDL playlists, but it is imperfect since you could concatenate multiple images in an EDL playlist (which should be done with the mf demuxer anyway). This is good enough anyway since the comment of the modified function already says it is "Imperfect and arbitrary".
This commit is contained in:
parent
00669dabd3
commit
9954fe01a9
|
@ -45,6 +45,7 @@ Interface changes
|
||||||
- make `current-window-scale` writeable and use it in the default input.conf
|
- make `current-window-scale` writeable and use it in the default input.conf
|
||||||
- add `--input-builtin-bindings` flag to control loading of built-in key
|
- add `--input-builtin-bindings` flag to control loading of built-in key
|
||||||
bindings during start-up (default: yes).
|
bindings during start-up (default: yes).
|
||||||
|
- add ``track-list/N/image`` sub-property
|
||||||
|
|
||||||
--- mpv 0.33.0 ---
|
--- mpv 0.33.0 ---
|
||||||
- add `--d3d11-exclusive-fs` flag to enable D3D11 exclusive fullscreen mode
|
- add `--d3d11-exclusive-fs` flag to enable D3D11 exclusive fullscreen mode
|
||||||
|
|
|
@ -2838,11 +2838,15 @@ Property list
|
||||||
``track-list/N/lang``
|
``track-list/N/lang``
|
||||||
Track language as identified by the file. Not always available.
|
Track language as identified by the file. Not always available.
|
||||||
|
|
||||||
``track-list/N/albumart``
|
``track-list/N/image``
|
||||||
``yes``/true if this is a video track that consists of a single
|
``yes``/true if this is a video track that consists of a single
|
||||||
picture, ``no``/false or unavailable otherwise. This is used for video
|
picture, ``no``/false or unavailable otherwise. The heuristic used to
|
||||||
tracks that are really images embedded in audio files and for external
|
determine if a stream is an image doesn't attempt to detect images in
|
||||||
cover art.
|
codecs normally used for videos. Otherwise, it is reliable.
|
||||||
|
|
||||||
|
``track-list/N/albumart``
|
||||||
|
``yes``/true if this is an image embedded in an audio file or external
|
||||||
|
cover art, ``no``/false or unavailable otherwise.
|
||||||
|
|
||||||
``track-list/N/default``
|
``track-list/N/default``
|
||||||
``yes``/true if the track has the default flag set in the file,
|
``yes``/true if the track has the default flag set in the file,
|
||||||
|
@ -2936,6 +2940,7 @@ Property list
|
||||||
"src-id" MPV_FORMAT_INT64
|
"src-id" MPV_FORMAT_INT64
|
||||||
"title" MPV_FORMAT_STRING
|
"title" MPV_FORMAT_STRING
|
||||||
"lang" MPV_FORMAT_STRING
|
"lang" MPV_FORMAT_STRING
|
||||||
|
"image" MPV_FORMAT_FLAG
|
||||||
"albumart" MPV_FORMAT_FLAG
|
"albumart" MPV_FORMAT_FLAG
|
||||||
"default" MPV_FORMAT_FLAG
|
"default" MPV_FORMAT_FLAG
|
||||||
"forced" MPV_FORMAT_FLAG
|
"forced" MPV_FORMAT_FLAG
|
||||||
|
|
|
@ -714,6 +714,7 @@ static void handle_new_stream(demuxer_t *demuxer, int i)
|
||||||
strcmp(priv->avif->name, "image2pipe") == 0
|
strcmp(priv->avif->name, "image2pipe") == 0
|
||||||
)) {
|
)) {
|
||||||
MP_VERBOSE(demuxer, "Assuming this is an image format.\n");
|
MP_VERBOSE(demuxer, "Assuming this is an image format.\n");
|
||||||
|
sh->image = true;
|
||||||
sh->codec->fps = priv->mf_fps;
|
sh->codec->fps = priv->mf_fps;
|
||||||
}
|
}
|
||||||
sh->codec->par_w = st->sample_aspect_ratio.num;
|
sh->codec->par_w = st->sample_aspect_ratio.num;
|
||||||
|
|
|
@ -381,8 +381,12 @@ static int demux_open_mf(demuxer_t *demuxer, enum demux_check check)
|
||||||
|
|
||||||
// create a new video stream header
|
// create a new video stream header
|
||||||
struct sh_stream *sh = demux_alloc_sh_stream(STREAM_VIDEO);
|
struct sh_stream *sh = demux_alloc_sh_stream(STREAM_VIDEO);
|
||||||
struct mp_codec_params *c = sh->codec;
|
if (mf->nr_of_files == 1) {
|
||||||
|
MP_VERBOSE(demuxer, "Assuming this is an image format.\n");
|
||||||
|
sh->image = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct mp_codec_params *c = sh->codec;
|
||||||
c->codec = codec;
|
c->codec = codec;
|
||||||
c->disp_w = 0;
|
c->disp_w = 0;
|
||||||
c->disp_h = 0;
|
c->disp_h = 0;
|
||||||
|
|
|
@ -1300,6 +1300,7 @@ static void add_coverart(struct demuxer *demuxer)
|
||||||
sh->attached_picture->pts = 0;
|
sh->attached_picture->pts = 0;
|
||||||
talloc_steal(sh, sh->attached_picture);
|
talloc_steal(sh, sh->attached_picture);
|
||||||
sh->attached_picture->keyframe = true;
|
sh->attached_picture->keyframe = true;
|
||||||
|
sh->image = true;
|
||||||
}
|
}
|
||||||
sh->title = att->name;
|
sh->title = att->name;
|
||||||
demux_add_sh_stream(demuxer, sh);
|
demux_add_sh_stream(demuxer, sh);
|
||||||
|
|
|
@ -525,6 +525,7 @@ static void apply_meta(struct sh_stream *dst, struct sh_stream *src)
|
||||||
dst->missing_timestamps = src->missing_timestamps;
|
dst->missing_timestamps = src->missing_timestamps;
|
||||||
if (src->attached_picture)
|
if (src->attached_picture)
|
||||||
dst->attached_picture = src->attached_picture;
|
dst->attached_picture = src->attached_picture;
|
||||||
|
dst->image = src->image;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is mostly for EDL user-defined metadata.
|
// This is mostly for EDL user-defined metadata.
|
||||||
|
|
|
@ -48,6 +48,7 @@ struct sh_stream {
|
||||||
bool dependent_track; // container dependent track flag
|
bool dependent_track; // container dependent track flag
|
||||||
bool visual_impaired_track; // container flag
|
bool visual_impaired_track; // container flag
|
||||||
bool hearing_impaired_track;// container flag
|
bool hearing_impaired_track;// container flag
|
||||||
|
bool image; // video stream is an image
|
||||||
bool still_image; // video stream contains still images
|
bool still_image; // video stream contains still images
|
||||||
int hls_bitrate;
|
int hls_bitrate;
|
||||||
|
|
||||||
|
|
|
@ -1949,6 +1949,7 @@ static int get_track_entry(int item, int action, void *arg, void *ctx)
|
||||||
.unavailable = !track->lang},
|
.unavailable = !track->lang},
|
||||||
{"audio-channels", SUB_PROP_INT(track_channels(track)),
|
{"audio-channels", SUB_PROP_INT(track_channels(track)),
|
||||||
.unavailable = track_channels(track) <= 0},
|
.unavailable = track_channels(track) <= 0},
|
||||||
|
{"image", SUB_PROP_FLAG(track->image)},
|
||||||
{"albumart", SUB_PROP_FLAG(track->attached_picture)},
|
{"albumart", SUB_PROP_FLAG(track->attached_picture)},
|
||||||
{"default", SUB_PROP_FLAG(track->default_track)},
|
{"default", SUB_PROP_FLAG(track->default_track)},
|
||||||
{"forced", SUB_PROP_FLAG(track->forced_track)},
|
{"forced", SUB_PROP_FLAG(track->forced_track)},
|
||||||
|
|
|
@ -136,6 +136,7 @@ struct track {
|
||||||
char *title;
|
char *title;
|
||||||
bool default_track, forced_track, dependent_track;
|
bool default_track, forced_track, dependent_track;
|
||||||
bool visual_impaired_track, hearing_impaired_track;
|
bool visual_impaired_track, hearing_impaired_track;
|
||||||
|
bool image;
|
||||||
bool attached_picture;
|
bool attached_picture;
|
||||||
char *lang;
|
char *lang;
|
||||||
|
|
||||||
|
|
|
@ -421,6 +421,7 @@ static struct track *add_stream_track(struct MPContext *mpctx,
|
||||||
.dependent_track = stream->dependent_track,
|
.dependent_track = stream->dependent_track,
|
||||||
.visual_impaired_track = stream->visual_impaired_track,
|
.visual_impaired_track = stream->visual_impaired_track,
|
||||||
.hearing_impaired_track = stream->hearing_impaired_track,
|
.hearing_impaired_track = stream->hearing_impaired_track,
|
||||||
|
.image = stream->image,
|
||||||
.attached_picture = stream->attached_picture != NULL,
|
.attached_picture = stream->attached_picture != NULL,
|
||||||
.lang = stream->lang,
|
.lang = stream->lang,
|
||||||
.demuxer = demuxer,
|
.demuxer = demuxer,
|
||||||
|
|
Loading…
Reference in New Issue