From 8f3d0b5e532a1dfb52145875d4ee4376d0e0188b Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 6 Dec 2013 23:00:19 +0100 Subject: player: load external subs for uncompressed rar archives Uncompressed rar archives can be transparently opened, but the filename the player doesn't have the direct filename (but something starting with rar://... instead). This will lead to external subtitles not being loaded. This doesn't handle multi-volume rar files, but in that cases just use the --autosub-match=fuzzy option. Fixes #397 on github. --- mpvcore/player/loadfile.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'mpvcore') diff --git a/mpvcore/player/loadfile.c b/mpvcore/player/loadfile.c index 3f23b21234..00b6a4b97c 100644 --- a/mpvcore/player/loadfile.c +++ b/mpvcore/player/loadfile.c @@ -697,8 +697,15 @@ static void open_subtitles_from_options(struct MPContext *mpctx) mp_add_subtitles(mpctx, mpctx->opts->sub_name[i]); } if (mpctx->opts->sub_auto) { // auto load sub file ... - struct subfn *list = find_text_subtitles(mpctx->opts, mpctx->filename); - for (int i = 0; list[i].fname; i++) { + void *tmp = talloc_new(NULL); + char *base_filename = mpctx->filename; + char *stream_filename = NULL; + if (stream_control(mpctx->stream, STREAM_CTRL_GET_BASE_FILENAME, + &stream_filename) > 0) + base_filename = talloc_steal(tmp, stream_filename); + struct subfn *list = find_text_subtitles(mpctx->opts, base_filename); + talloc_steal(tmp, list); + for (int i = 0; list && list[i].fname; i++) { char *filename = list[i].fname; char *lang = list[i].lang; for (int n = 0; n < mpctx->num_sources; n++) { @@ -713,7 +720,7 @@ static void open_subtitles_from_options(struct MPContext *mpctx) } skip:; } - talloc_free(list); + talloc_free(tmp); } } -- cgit v1.2.3