Skip to content

Commit

Permalink
command: add demuxer-lavf-list property
Browse files Browse the repository at this point in the history
Was only available with --demuxer-lavf-format=help and the demuxer
needed to be used for it to actually print the list.

This can be used in the future to check if 'dash' support was compiled
with FFmpeg so ytdl_hook can use it instead. For now, dashdec is too
rudimentary to be used right away.
  • Loading branch information
wiiaboo committed Jan 2, 2018
1 parent 89f81da commit 828bd29
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions DOCS/man/input.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2119,6 +2119,10 @@ Property list
The encoder names (``driver`` entries) can be passed to ``--ovc`` and
``--oac`` (without the ``lavc:`` prefix required by ``--vd`` and ``--ad``).

``demuxer-lavf-list``
List of available libavformat demuxers' names. This can be used to check
for support for a specific format or use with ``--demuxer-lavf-format``.

``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.
Expand Down
17 changes: 17 additions & 0 deletions common/av_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
#include <libavutil/error.h>
#include <libavutil/cpu.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>

#include "config.h"

#include "common/common.h"
#include "common/msg.h"
#include "demux/packet.h"
#include "demux/stheader.h"
#include "misc/bstr.h"
#include "video/fmt-conversion.h"
#include "av_common.h"
#include "codecs.h"
Expand Down Expand Up @@ -246,6 +248,21 @@ void mp_add_lavc_encoders(struct mp_decoder_list *list)
}
}

char **mp_get_lavf_demuxers(void)
{
char **list = NULL;
AVInputFormat *cur = NULL;
int num = 0;
for (;;) {
cur = av_iformat_next(cur);
if (!cur)
break;
MP_TARRAY_APPEND(NULL, list, num, talloc_strdup(NULL, cur->name));
}
MP_TARRAY_APPEND(NULL, list, num, NULL);
return list;
}

int mp_codec_to_av_codec_id(const char *codec)
{
int id = AV_CODEC_ID_NONE;
Expand Down
1 change: 1 addition & 0 deletions common/av_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ 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);
char **mp_get_lavf_demuxers(void);
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);
Expand Down
15 changes: 15 additions & 0 deletions player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -3588,6 +3588,20 @@ static int mp_property_encoders(void *ctx, struct m_property *prop,
return r;
}

static int mp_property_lavf_demuxers(void *ctx, struct m_property *prop,
int action, void *arg)
{
switch (action) {
case M_PROPERTY_GET:
*(char ***)arg = mp_get_lavf_demuxers();
return M_PROPERTY_OK;
case M_PROPERTY_GET_TYPE:
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
return M_PROPERTY_OK;
}
return M_PROPERTY_NOT_IMPLEMENTED;
}

static int mp_property_version(void *ctx, struct m_property *prop,
int action, void *arg)
{
Expand Down Expand Up @@ -4027,6 +4041,7 @@ static const struct m_property mp_properties_base[] = {
{"protocol-list", mp_property_protocols},
{"decoder-list", mp_property_decoders},
{"encoder-list", mp_property_encoders},
{"demuxer-lavf-list", mp_property_lavf_demuxers},

{"mpv-version", mp_property_version},
{"mpv-configuration", mp_property_configuration},
Expand Down

0 comments on commit 828bd29

Please sign in to comment.