summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-03-01 21:46:49 +0100
committerwm4 <wm4@nowhere>2016-03-01 21:46:57 +0100
commit33774e18ed4c49857c042870099e3e3dd6fe614d (patch)
treed19275a23ca9ea6551a52bca99d62b0d9493edd5
parentaf66fa8fa5d8e46b26a08a2b241f03d46abb3c2b (diff)
downloadmpv-33774e18ed4c49857c042870099e3e3dd6fe614d.tar.bz2
mpv-33774e18ed4c49857c042870099e3e3dd6fe614d.tar.xz
command: add encoder-list property
Also change decoder-list (for the sake of sharing the underlying code for both properties).
-rw-r--r--DOCS/man/input.rst9
-rw-r--r--common/av_common.c15
-rw-r--r--common/av_common.h1
-rw-r--r--player/command.c15
4 files changed, 37 insertions, 3 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 6dcf7a83e4..0cdb611583 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -1999,7 +1999,7 @@ Property list
Canonical codec name, which identifies the format the decoder can
handle.
- ``decoder``
+ ``driver``
The name of the decoder itself. Often, this is the same as ``codec``.
Sometimes it can be different. It is used to distinguish multiple
decoders for the same codec.
@@ -2017,9 +2017,14 @@ Property list
MPV_FORMAT_NODE_MAP (for each decoder entry)
"family" MPV_FORMAT_STRING
"codec" MPV_FORMAT_STRING
- "decoder" MPV_FORMAT_STRING
+ "driver" MPV_FORMAT_STRING
"description" MPV_FORMAT_STRING
+``encoder-list``
+ List of libavcodec encoders. This has the same format as ``decoder-list``.
+ The encoder names (``driver`` entries) can be passed to ``--ovc`` and
+ ``--oac`` (without the ``lavc:`` prefix required by ``--vd`` and ``--ad``).
+
``mpv-version``
Return the mpv version/copyright string. Depending on how the binary was
built, it might contain either a release version, or just a git hash.
diff --git a/common/av_common.c b/common/av_common.c
index 8b979cabba..5cb434f969 100644
--- a/common/av_common.c
+++ b/common/av_common.c
@@ -158,6 +158,21 @@ void mp_add_lavc_decoders(struct mp_decoder_list *list, enum AVMediaType type)
}
}
+// (Abuses the decoder list data structures.)
+void mp_add_lavc_encoders(struct mp_decoder_list *list)
+{
+ AVCodec *cur = NULL;
+ for (;;) {
+ cur = av_codec_next(cur);
+ if (!cur)
+ break;
+ if (av_codec_is_encoder(cur)) {
+ mp_add_decoder(list, "lavc", mp_codec_from_av_codec_id(cur->id),
+ cur->name, cur->long_name);
+ }
+ }
+}
+
int mp_codec_to_av_codec_id(const char *codec)
{
int id = AV_CODEC_ID_NONE;
diff --git a/common/av_common.h b/common/av_common.h
index e9df328fbf..1478adf8fb 100644
--- a/common/av_common.h
+++ b/common/av_common.h
@@ -36,6 +36,7 @@ int64_t mp_pts_to_av(double mp_pts, AVRational *tb);
double mp_pts_from_av(int64_t av_pts, AVRational *tb);
void mp_set_avcodec_threads(struct mp_log *l, AVCodecContext *avctx, int threads);
void mp_add_lavc_decoders(struct mp_decoder_list *list, enum AVMediaType type);
+void mp_add_lavc_encoders(struct mp_decoder_list *list);
int mp_codec_to_av_codec_id(const char *codec);
const char *mp_codec_from_av_codec_id(int codec_id);
void mp_set_avdict(struct AVDictionary **dict, char **kv);
diff --git a/player/command.c b/player/command.c
index 9dc46900f2..275effb5a4 100644
--- a/player/command.c
+++ b/player/command.c
@@ -32,6 +32,7 @@
#include "config.h"
#include "mpv_talloc.h"
#include "client.h"
+#include "common/av_common.h"
#include "common/codecs.h"
#include "common/msg.h"
#include "common/msg_control.h"
@@ -3299,7 +3300,7 @@ static int get_decoder_entry(int item, int action, void *arg, void *ctx)
struct m_sub_property props[] = {
{"family", SUB_PROP_STR(c->family)},
{"codec", SUB_PROP_STR(c->codec)},
- {"decoder", SUB_PROP_STR(c->decoder)},
+ {"driver" , SUB_PROP_STR(c->decoder)},
{"description", SUB_PROP_STR(c->desc)},
{0}
};
@@ -3321,6 +3322,17 @@ static int mp_property_decoders(void *ctx, struct m_property *prop,
return r;
}
+static int mp_property_encoders(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ struct mp_decoder_list *codecs = talloc_zero(NULL, struct mp_decoder_list);
+ mp_add_lavc_encoders(codecs);
+ int r = m_property_read_list(action, arg, codecs->num_entries,
+ get_decoder_entry, codecs);
+ talloc_free(codecs);
+ return r;
+}
+
static int mp_property_version(void *ctx, struct m_property *prop,
int action, void *arg)
{
@@ -3749,6 +3761,7 @@ static const struct m_property mp_properties[] = {
{"protocol-list", mp_property_protocols},
{"decoder-list", mp_property_decoders},
+ {"encoder-list", mp_property_encoders},
{"mpv-version", mp_property_version},
{"mpv-configuration", mp_property_configuration},