mirror of
https://github.com/mpv-player/mpv
synced 2025-03-20 02:09:52 +00:00
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.
This commit is contained in:
parent
a53abbf4a6
commit
8f3d0b5e53
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,6 +100,7 @@ enum stream_ctrl {
|
||||
STREAM_CTRL_GET_DVD_INFO,
|
||||
STREAM_CTRL_SET_CONTENTS,
|
||||
STREAM_CTRL_GET_METADATA,
|
||||
STREAM_CTRL_GET_BASE_FILENAME,
|
||||
};
|
||||
|
||||
struct stream_lang_req {
|
||||
|
@ -75,6 +75,17 @@ static void rar_entry_close(stream_t *s)
|
||||
RarFileDelete(rar_file);
|
||||
}
|
||||
|
||||
static int rar_entry_control(stream_t *s, int cmd, void *arg)
|
||||
{
|
||||
rar_file_t *rar_file = s->priv;
|
||||
switch (cmd) {
|
||||
case STREAM_CTRL_GET_BASE_FILENAME:
|
||||
*(char **)arg = talloc_strdup(NULL, rar_file->s->url);
|
||||
return STREAM_OK;
|
||||
}
|
||||
return STREAM_UNSUPPORTED;
|
||||
}
|
||||
|
||||
static int rar_entry_open(stream_t *stream, int mode)
|
||||
{
|
||||
if (!strchr(stream->path, '|'))
|
||||
@ -123,6 +134,7 @@ static int rar_entry_open(stream_t *stream, int mode)
|
||||
stream->fill_buffer = rar_entry_fill_buffer;
|
||||
stream->seek = rar_entry_seek;
|
||||
stream->close = rar_entry_close;
|
||||
stream->control = rar_entry_control;
|
||||
|
||||
return STREAM_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user