diff options
author | wm4 <wm4@nowhere> | 2013-12-06 23:00:19 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-12-06 23:00:19 +0100 |
commit | 8f3d0b5e532a1dfb52145875d4ee4376d0e0188b (patch) | |
tree | 6b3b593981edf221de7c6d3973986b4416727423 /mpvcore | |
parent | a53abbf4a68fdd700d6ef16e5a26db53d66e73c3 (diff) | |
download | mpv-8f3d0b5e532a1dfb52145875d4ee4376d0e0188b.tar.bz2 mpv-8f3d0b5e532a1dfb52145875d4ee4376d0e0188b.tar.xz |
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.
Diffstat (limited to 'mpvcore')
-rw-r--r-- | mpvcore/player/loadfile.c | 13 |
1 files changed, 10 insertions, 3 deletions
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); } } |