mirror of
https://github.com/mpv-player/mpv
synced 2024-11-03 03:19:24 +01:00
player: select fallback stream in timeline code for better EDL handling
The intention of the existing code was trying to match demuxer-reported stream IDs, instead of using possibly arbitrary ordering of the frontend track list. But EDL files can consist of quite different files, for which trying to match the stream IDs doesn't always make sense.
This commit is contained in:
parent
904ae96795
commit
b0c75a1ff9
@ -355,6 +355,23 @@ static void preselect_demux_streams(struct MPContext *mpctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct sh_stream *select_fallback_stream(struct demuxer *d,
|
||||||
|
enum stream_type type,
|
||||||
|
int index)
|
||||||
|
{
|
||||||
|
struct sh_stream *best_stream = NULL;
|
||||||
|
for (int n = 0; n < d->num_streams; n++) {
|
||||||
|
struct sh_stream *s = d->streams[n];
|
||||||
|
if (s->type == type) {
|
||||||
|
best_stream = s;
|
||||||
|
if (index == 0)
|
||||||
|
break;
|
||||||
|
index -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return best_stream;
|
||||||
|
}
|
||||||
|
|
||||||
bool timeline_set_part(struct MPContext *mpctx, int i, bool force)
|
bool timeline_set_part(struct MPContext *mpctx, int i, bool force)
|
||||||
{
|
{
|
||||||
struct timeline_part *p = mpctx->timeline + mpctx->timeline_part;
|
struct timeline_part *p = mpctx->timeline + mpctx->timeline_part;
|
||||||
@ -381,6 +398,12 @@ bool timeline_set_part(struct MPContext *mpctx, int i, bool force)
|
|||||||
track->stream = demuxer_stream_by_demuxer_id(track->demuxer,
|
track->stream = demuxer_stream_by_demuxer_id(track->demuxer,
|
||||||
track->type,
|
track->type,
|
||||||
track->demuxer_id);
|
track->demuxer_id);
|
||||||
|
// EDL can have mismatched files in the same timeline
|
||||||
|
if (!track->stream) {
|
||||||
|
track->stream = select_fallback_stream(track->demuxer,
|
||||||
|
track->type,
|
||||||
|
track->user_tid - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
preselect_demux_streams(mpctx);
|
preselect_demux_streams(mpctx);
|
||||||
|
Loading…
Reference in New Issue
Block a user