mirror of
https://github.com/mpv-player/mpv
synced 2025-02-16 12:17:12 +00:00
demux: add a format-name property
It can be useful to know the underlying format of any entry in the track list. Only applicable to the lavf demuxer.
This commit is contained in:
parent
8a9749b8a5
commit
ccafd40ccc
@ -3089,6 +3089,11 @@ Property list
|
|||||||
``track-list/N/demux-par``
|
``track-list/N/demux-par``
|
||||||
Pixel aspect ratio.
|
Pixel aspect ratio.
|
||||||
|
|
||||||
|
``track-list/N/format-name``
|
||||||
|
Short name for format from ffmpeg. If the track is audio, this will be
|
||||||
|
the name of the sample format. If the track is video, this will be the
|
||||||
|
name of the pixel format.
|
||||||
|
|
||||||
``track-list/N/audio-channels`` (deprecated)
|
``track-list/N/audio-channels`` (deprecated)
|
||||||
Deprecated alias for ``track-list/N/demux-channel-count``.
|
Deprecated alias for ``track-list/N/demux-channel-count``.
|
||||||
|
|
||||||
|
@ -29,14 +29,15 @@
|
|||||||
|
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
#include <libavformat/avio.h>
|
#include <libavformat/avio.h>
|
||||||
|
|
||||||
#include <libavutil/avutil.h>
|
#include <libavutil/avutil.h>
|
||||||
#include <libavutil/avstring.h>
|
#include <libavutil/avstring.h>
|
||||||
#include <libavutil/mathematics.h>
|
|
||||||
#include <libavutil/replaygain.h>
|
|
||||||
#include <libavutil/display.h>
|
#include <libavutil/display.h>
|
||||||
#include <libavutil/opt.h>
|
|
||||||
|
|
||||||
#include <libavutil/dovi_meta.h>
|
#include <libavutil/dovi_meta.h>
|
||||||
|
#include <libavutil/mathematics.h>
|
||||||
|
#include <libavutil/opt.h>
|
||||||
|
#include <libavutil/pixdesc.h>
|
||||||
|
#include <libavutil/replaygain.h>
|
||||||
|
|
||||||
#include "audio/chmap_avchannel.h"
|
#include "audio/chmap_avchannel.h"
|
||||||
|
|
||||||
@ -726,6 +727,7 @@ static void handle_new_stream(demuxer_t *demuxer, int i)
|
|||||||
|
|
||||||
sh->codec->samplerate = codec->sample_rate;
|
sh->codec->samplerate = codec->sample_rate;
|
||||||
sh->codec->bitrate = codec->bit_rate;
|
sh->codec->bitrate = codec->bit_rate;
|
||||||
|
sh->codec->format_name = talloc_strdup(sh, av_get_sample_fmt_name(codec->format));
|
||||||
|
|
||||||
double delay = 0;
|
double delay = 0;
|
||||||
if (codec->sample_rate > 0)
|
if (codec->sample_rate > 0)
|
||||||
@ -764,6 +766,7 @@ static void handle_new_stream(demuxer_t *demuxer, int i)
|
|||||||
|
|
||||||
sh->codec->disp_w = codec->width;
|
sh->codec->disp_w = codec->width;
|
||||||
sh->codec->disp_h = codec->height;
|
sh->codec->disp_h = codec->height;
|
||||||
|
sh->codec->format_name = talloc_strdup(sh, av_get_pix_fmt_name(codec->format));
|
||||||
if (st->avg_frame_rate.num)
|
if (st->avg_frame_rate.num)
|
||||||
sh->codec->fps = av_q2d(st->avg_frame_rate);
|
sh->codec->fps = av_q2d(st->avg_frame_rate);
|
||||||
if (is_image(st, sh->attached_picture, priv->avif)) {
|
if (is_image(st, sh->attached_picture, priv->avif)) {
|
||||||
|
@ -111,6 +111,7 @@ struct mp_codec_params {
|
|||||||
|
|
||||||
// STREAM_VIDEO + STREAM_AUDIO
|
// STREAM_VIDEO + STREAM_AUDIO
|
||||||
int bits_per_coded_sample;
|
int bits_per_coded_sample;
|
||||||
|
char *format_name; // pixel format (video) or sample format (audio)
|
||||||
|
|
||||||
// STREAM_SUB
|
// STREAM_SUB
|
||||||
double frame_based; // timestamps are frame-based (and this is the
|
double frame_based; // timestamps are frame-based (and this is the
|
||||||
|
@ -2063,6 +2063,7 @@ static int get_track_entry(int item, int action, void *arg, void *ctx)
|
|||||||
{"demux-bitrate", SUB_PROP_INT(p.bitrate), .unavailable = p.bitrate <= 0},
|
{"demux-bitrate", SUB_PROP_INT(p.bitrate), .unavailable = p.bitrate <= 0},
|
||||||
{"demux-rotation", SUB_PROP_INT(p.rotate), .unavailable = p.rotate <= 0},
|
{"demux-rotation", SUB_PROP_INT(p.rotate), .unavailable = p.rotate <= 0},
|
||||||
{"demux-par", SUB_PROP_DOUBLE(par), .unavailable = par <= 0},
|
{"demux-par", SUB_PROP_DOUBLE(par), .unavailable = par <= 0},
|
||||||
|
{"format-name", SUB_PROP_STR(p.format_name), .unavailable = !p.format_name},
|
||||||
{"replaygain-track-peak", SUB_PROP_FLOAT(rg.track_peak),
|
{"replaygain-track-peak", SUB_PROP_FLOAT(rg.track_peak),
|
||||||
.unavailable = !has_rg},
|
.unavailable = !has_rg},
|
||||||
{"replaygain-track-gain", SUB_PROP_FLOAT(rg.track_gain),
|
{"replaygain-track-gain", SUB_PROP_FLOAT(rg.track_gain),
|
||||||
|
Loading…
Reference in New Issue
Block a user