-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
select.lua: strip filename from the display of external track titles #15942
base: master
Are you sure you want to change the base?
Conversation
9380b6b
to
446ae32
Compare
I wouldn't try to mimic external file selection logic from core. Instead I would just strip the common part of filename from the beginning of the external one. This way it will not show redundant long video file name part, but show all the remaining additional things like language (it's already there), but more importantly the the extension of the audio file. Imagine you have two files with the same language, |
Download the artifacts for this pull request: |
446ae32
to
2b033f1
Compare
Makes sense, keep the extension instead. |
2b033f1
to
49e985b
Compare
It doesn't make much sense to display them, streamline the display as much as possible and avoid excessively long external titles
49e985b
to
87015b1
Compare
Should we change |
Actually, I'm not sure we want to strip the filename for all external tracks. For audio streams sure, but for external subtitles, they may not necessary have all the proper metadata to identify which is which except the filename. see the following example: I think the filename should always be there. |
It is not necessary to display the video filename in an external track, which is redundant information. For subtitles, the necessary information is language identification and codec. In your screenshot, the external subtitles have shown the necessary information: extensions and additional Information(may be language suffixes). And when the external track file does not contain the video filename, the filename will still be retained intact, which I think is enough. |
I think it's too radical to keep the extensions only, and there's other useful information in the external track files besides the extension: possible language suffixes or additional Information. And when the external track name does not contain the video file name, it should be retained intact, for example: |
How about we just strip the common part of the main filename from external track title? diff --git a/player/loadfile.c b/player/loadfile.c
index af563f7464..0fa93d569a 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -903,7 +903,13 @@ int mp_add_external_file(struct MPContext *mpctx, char *filename,
if (sh->title && sh->title[0]) {
t->title = talloc_strdup(t, sh->title);
} else {
- t->title = talloc_strdup(t, mp_basename(disp_filename));
+ bstr parent_filename = {0};
+ if (mpctx->filename)
+ parent_filename = bstr_strip_ext(bstr0(mp_basename(mpctx->filename)));
+ bstr title = bstr0(mp_basename(disp_filename));
+ bstr_eatstart(&title, parent_filename);
+ bstr_eatstart(&title, bstr0("."));
+ t->title = bstrdup0(t, title);
}
t->external_filename = mp_normalize_user_path(t, mpctx->global, filename);
t->no_default = sh->type != filter; Or if we want to keep it simpler and just strip the common part diff --git a/player/loadfile.c b/player/loadfile.c
index af563f7464..162d57190e 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -903,7 +903,13 @@ int mp_add_external_file(struct MPContext *mpctx, char *filename,
if (sh->title && sh->title[0]) {
t->title = talloc_strdup(t, sh->title);
} else {
- t->title = talloc_strdup(t, mp_basename(disp_filename));
+ char *title = mp_basename(disp_filename);
+ char *parent = mpctx->filename ? mp_basename(mpctx->filename) : NULL;
+ while (*title && *parent && *title == *parent) {
+ title++;
+ parent++;
+ }
+ t->title = talloc_strdup(t, title);
}
t->external_filename = mp_normalize_user_path(t, mpctx->global, filename);
t->no_default = sh->type != filter; |
I prefer this implementation, another implementation will retain the |
It doesn't make much sense to display them, streamline the display as much as possible and avoid excessively long external titles
Before:


After: