summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-19 22:18:56 +0100
committerwm4 <wm4@nowhere>2013-11-19 22:18:56 +0100
commitb0c75a1ff99dfbc8ab0e7a932e143da6a2cfc952 (patch)
treeb5237937d888c3d963bdba5a985439dda5e10698
parent904ae967959b1edf72de44c3a5f78bdb096ad330 (diff)
downloadmpv-b0c75a1ff99dfbc8ab0e7a932e143da6a2cfc952.tar.bz2
mpv-b0c75a1ff99dfbc8ab0e7a932e143da6a2cfc952.tar.xz
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.
-rw-r--r--mpvcore/player/loadfile.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/mpvcore/player/loadfile.c b/mpvcore/player/loadfile.c
index f787b5e495..5dd94106dd 100644
--- a/mpvcore/player/loadfile.c
+++ b/mpvcore/player/loadfile.c
@@ -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)
{
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->type,
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);