From ccafd40ccce83d9857e61361126bd474d4b712e8 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Sat, 28 Oct 2023 00:41:57 -0500 Subject: 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. --- demux/demux_lavf.c | 11 +++++++---- demux/stheader.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'demux') diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index bb7b38f9a8..fa9fd5cee8 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -29,14 +29,15 @@ #include #include + #include #include -#include -#include #include -#include - #include +#include +#include +#include +#include #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->bitrate = codec->bit_rate; + sh->codec->format_name = talloc_strdup(sh, av_get_sample_fmt_name(codec->format)); double delay = 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_h = codec->height; + sh->codec->format_name = talloc_strdup(sh, av_get_pix_fmt_name(codec->format)); if (st->avg_frame_rate.num) sh->codec->fps = av_q2d(st->avg_frame_rate); if (is_image(st, sh->attached_picture, priv->avif)) { diff --git a/demux/stheader.h b/demux/stheader.h index cb6cc3e579..438ef7db41 100644 --- a/demux/stheader.h +++ b/demux/stheader.h @@ -111,6 +111,7 @@ struct mp_codec_params { // STREAM_VIDEO + STREAM_AUDIO int bits_per_coded_sample; + char *format_name; // pixel format (video) or sample format (audio) // STREAM_SUB double frame_based; // timestamps are frame-based (and this is the -- cgit v1.2.3