mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
player: add stream selection by ffmpeg index
Apparently using the stream index is the best way to refer to the same streams across multiple FFmpeg-using programs, even if the stream index itself is rarely meaningful in any way. For Matroska, there are some possible problems, depending how FFmpeg actually adds streams. Normally they seem to match though.
This commit is contained in:
@@ -190,6 +190,7 @@ struct sh_stream *new_sh_stream(demuxer_t *demuxer, enum stream_type type)
|
||||
*sh = (struct sh_stream) {
|
||||
.type = type,
|
||||
.index = demuxer->num_streams,
|
||||
.ff_index = demuxer->num_streams,
|
||||
.demuxer_id = demuxer_id, // may be overwritten by demuxer
|
||||
.ds = talloc(sh, struct demux_stream),
|
||||
};
|
||||
|
||||
@@ -587,6 +587,7 @@ static void handle_stream(demuxer_t *demuxer, int i)
|
||||
MP_TARRAY_APPEND(priv, priv->streams, priv->num_streams, sh);
|
||||
|
||||
if (sh) {
|
||||
sh->ff_index = st->index;
|
||||
sh->codec = mp_codec_from_av_codec_id(codec->codec_id);
|
||||
sh->lav_headers = codec;
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ struct sh_stream {
|
||||
// Demuxer/format specific ID. Corresponds to the stream IDs as encoded in
|
||||
// some file formats (e.g. MPEG), or an index chosen by demux.c.
|
||||
int demuxer_id;
|
||||
// FFmpeg stream index (AVFormatContext.streams[index]), or equivalent.
|
||||
int ff_index;
|
||||
// One of these is non-NULL, the others are NULL, depending on the stream
|
||||
// type.
|
||||
struct sh_audio *audio;
|
||||
|
||||
Reference in New Issue
Block a user