History

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.

Dudemanguy committed 3 years ago

Commit ccafd401 parent 8a9749b4 files · +14 −4Browse files

Unified · Split

4 files
  1. DOCS/man/input.rst +5 −0
  2. demux/demux_lavf.c +7 −4
  3. demux/stheader.h +1 −0
  4. player/command.c +1 −0
DOCS/man/input.rst+5−0
@@ -3089,6 +3089,11 @@ Property list · 3088 unmodified lines
30893089 ``track-list/N/demux-par``
30903090 Pixel aspect ratio.
30913091
3092+ ``track-list/N/format-name``
3093+ Short name for format from ffmpeg. If the track is audio, this will be
3094+ the name of the sample format. If the track is video, this will be the
3095+ name of the pixel format.
3096+
30923097 ``track-list/N/audio-channels`` (deprecated)
30933098 Deprecated alias for ``track-list/N/demux-channel-count``.
30943099
demux/demux_lavf.c+7−4
@@ -29,14 +29,15 @@ · 28 unmodified lines
2929
3030 #include <libavformat/avformat.h>
3131 #include <libavformat/avio.h>
32+
3233 #include <libavutil/avutil.h>
3334 #include <libavutil/avstring.h>
34−#include <libavutil/mathematics.h>
35−#include <libavutil/replaygain.h>
3635 #include <libavutil/display.h>
37−#include <libavutil/opt.h>
38−
3936 #include <libavutil/dovi_meta.h>
37+#include <libavutil/mathematics.h>
38+#include <libavutil/opt.h>
39+#include <libavutil/pixdesc.h>
40+#include <libavutil/replaygain.h>
4041
4142 #include "audio/chmap_avchannel.h"
4243
@@ -726,6 +727,7 @@ static void handle_new_stream(demuxer_t *demuxer, int i) · 683 unmodified lines
726727
727728 sh->codec->samplerate = codec->sample_rate;
728729 sh->codec->bitrate = codec->bit_rate;
730+ sh->codec->format_name = talloc_strdup(sh, av_get_sample_fmt_name(codec->format));
729731
730732 double delay = 0;
731733 if (codec->sample_rate > 0)
@@ -764,6 +766,7 @@ static void handle_new_stream(demuxer_t *demuxer, int i) · 32 unmodified lines
764766
765767 sh->codec->disp_w = codec->width;
766768 sh->codec->disp_h = codec->height;
769+ sh->codec->format_name = talloc_strdup(sh, av_get_pix_fmt_name(codec->format));
767770 if (st->avg_frame_rate.num)
768771 sh->codec->fps = av_q2d(st->avg_frame_rate);
769772 if (is_image(st, sh->attached_picture, priv->avif)) {
demux/stheader.h+1−0
@@ -111,6 +111,7 @@ struct mp_codec_params { · 110 unmodified lines
111111
112112 // STREAM_VIDEO + STREAM_AUDIO
113113 int bits_per_coded_sample;
114+ char *format_name; // pixel format (video) or sample format (audio)
114115
115116 // STREAM_SUB
116117 double frame_based; // timestamps are frame-based (and this is the
player/command.c+1−0
@@ -2063,6 +2063,7 @@ static int get_track_entry(int item, int action, void *arg, void *ctx) · 2062 unmodified lines
20632063 {"demux-bitrate", SUB_PROP_INT(p.bitrate), .unavailable = p.bitrate <= 0},
20642064 {"demux-rotation", SUB_PROP_INT(p.rotate), .unavailable = p.rotate <= 0},
20652065 {"demux-par", SUB_PROP_DOUBLE(par), .unavailable = par <= 0},
2066+ {"format-name", SUB_PROP_STR(p.format_name), .unavailable = !p.format_name},
20662067 {"replaygain-track-peak", SUB_PROP_FLOAT(rg.track_peak),
20672068 .unavailable = !has_rg},
20682069 {"replaygain-track-gain", SUB_PROP_FLOAT(rg.track_gain),

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t