summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-02-29 20:55:44 +0100
committerwm4 <wm4@nowhere>2016-02-29 20:56:08 +0100
commit0a1e926670a5563df788f9c732a93e3230d86182 (patch)
tree1ca336f3893859fdd40aff32597484fcd136ed8c
parent041c9f1782cbed4abf7793f4e72b8b29b2fd9b1b (diff)
downloadmpv-0a1e926670a5563df788f9c732a93e3230d86182.tar.bz2
mpv-0a1e926670a5563df788f9c732a93e3230d86182.tar.xz
command: export more information under track-list
Export a number of container fields, which may or may not be useful in some scenarios. They are explicitly marked as originating from the demuxer, in order to make it explicit that they might be unreliable. I'd actually like to remove all other cases where container information is exported, but those numerous cases are going to be somewhat hard to deprecate. Also, not directly related, export the description of the currently active decoder. (This has been requested before.)
-rw-r--r--DOCS/interface-changes.rst3
-rw-r--r--DOCS/man/input.rst36
-rw-r--r--player/command.c24
3 files changed, 55 insertions, 8 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index 4217de86fc..1298c24d6d 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -19,6 +19,9 @@ Interface changes
::
+ --- mpv 0.17.0 ---
+ - deprecate "track-list/N/audio-channels" property (use
+ "track-list/N/demux-channel-count" instead)
--- mpv 0.16.0 ---
- change --audio-channels default to stereo (use --audio-channels=auto to
get the old default)
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 11a8f0021f..9918f7384f 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -1707,10 +1707,6 @@ Property list
``track-list/N/lang``
Track language as identified by the file. Not always available.
- ``track-list/N/audio-channels``
- For audio tracks, the number of audio channels in the audio stream.
- Not always accurate (depends on container hints). Not always available.
-
``track-list/N/albumart``
``yes`` if this is a video track that consists of a single picture,
``no`` or unavailable otherwise. This is used for video tracks that are
@@ -1746,6 +1742,29 @@ Property list
match even if the default (builtin) demuxer is used, but there is
no hard guarantee.
+ ``track-list/N/decoder-desc``
+ If this track is being decoded, the human-readable decoder name,
+
+ ``track-list/N/demux-w``, ``track-list/N/demux-h``
+ Video size hint as indicated by the container. (Not always accurate.)
+
+ ``track-list/N/demux-channel-count``
+ Number of audio channels as indicated by the container. (Not always
+ accurate - in particular, the track could be decoded as a different
+ number of channels.)
+
+ ``track-list/N/demux-channels``
+ Channel layout as indicated by the container. (Not always accurate.)
+
+ ``track-list/N/demux-samplerate``
+ Audio sample rate as indicated by the container. (Not always accurate.)
+
+ ``track-list/N/demux-fps``
+ Video FPS as indicated by the container. (Not always accurate.)
+
+ ``track-list/N/audio-channels`` (deprecated)
+ Deprecated alias for ``track-list/N/demux-channel-count``.
+
When querying the property with the client API using ``MPV_FORMAT_NODE``,
or with Lua ``mp.get_property_native``, this will return a mpv_node with
the following contents:
@@ -1759,13 +1778,20 @@ Property list
"src-id" MPV_FORMAT_INT64
"title" MPV_FORMAT_STRING
"lang" MPV_FORMAT_STRING
- "audio-channels" MPV_FORMAT_INT64
"albumart" MPV_FORMAT_FLAG
"default" MPV_FORMAT_FLAG
"forced" MPV_FORMAT_FLAG
"external" MPV_FORMAT_FLAG
"external-filename" MPV_FORMAT_STRING
"codec" MPV_FORMAT_STRING
+ "decoder-desc" MPV_FORMAT_STRING
+ "demux-w" MPV_FORMAT_INT64
+ "demux-h" MPV_FORMAT_INT64
+ "demux-channel-count" MPV_FORMAT_INT64
+ "demux-channels" MPV_FORMAT_STRING
+ "demux-samplerate" MPV_FORMAT_INT64
+ "demux-fps" MPV_FORMAT_DOUBLE
+ "audio-channels" MPV_FORMAT_INT64
``chapter-list``
List of chapters, current entry marked. Currently, the raw property value
diff --git a/player/command.c b/player/command.c
index 642330e34f..421f001573 100644
--- a/player/command.c
+++ b/player/command.c
@@ -1944,7 +1944,14 @@ static int get_track_entry(int item, int action, void *arg, void *ctx)
struct MPContext *mpctx = ctx;
struct track *track = mpctx->tracks[item];
- const char *codec = track->stream ? track->stream->codec->codec : NULL;
+ struct mp_codec_params p =
+ track->stream ? *track->stream->codec : (struct mp_codec_params){0};
+
+ const char *decoder_desc = NULL;
+ if (track->d_video)
+ decoder_desc = track->d_video->decoder_desc;
+ if (track->d_audio)
+ decoder_desc = track->d_audio->decoder_desc;
struct m_sub_property props[] = {
{"id", SUB_PROP_INT(track->user_tid)},
@@ -1965,9 +1972,20 @@ static int get_track_entry(int item, int action, void *arg, void *ctx)
{"selected", SUB_PROP_FLAG(track->selected)},
{"external-filename", SUB_PROP_STR(track->external_filename),
.unavailable = !track->external_filename},
- {"codec", SUB_PROP_STR(codec),
- .unavailable = !codec},
{"ff-index", SUB_PROP_INT(track->ff_index)},
+ {"decoder-desc", SUB_PROP_STR(decoder_desc),
+ .unavailable = !decoder_desc},
+ {"codec", SUB_PROP_STR(p.codec),
+ .unavailable = !p.codec},
+ {"demux-w", SUB_PROP_INT(p.disp_w), .unavailable = !p.disp_w},
+ {"demux-h", SUB_PROP_INT(p.disp_h), .unavailable = !p.disp_h},
+ {"demux-channel-count", SUB_PROP_INT(p.channels.num),
+ .unavailable = !p.channels.num},
+ {"demux-channels", SUB_PROP_STR(mp_chmap_to_str(&p.channels)),
+ .unavailable = !p.channels.num},
+ {"demux-samplerate", SUB_PROP_INT(p.samplerate),
+ .unavailable = !p.samplerate},
+ {"demux-fps", SUB_PROP_DOUBLE(p.fps), .unavailable = p.fps <= 0},
{0}
};