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

Feature request: autoload subtitle tracks in mka files when opening a mkv file with --audio-file-auto and --sub-auto #5132

Closed
zc62 opened this Issue Nov 20, 2017 · 9 comments

Comments

Projects
None yet
3 participants
@zc62
Contributor

zc62 commented Nov 20, 2017

Although mka is designed to have audio only in Matroska standard, there do exist many mka files containing not only audio tracks, but also subtitle tracks. As mentioned in issue #2663, mpv is able to load mka files as external subtitle files via the --sub-file option, however, I think it is probably more natural to let the --sub-auto option automatically handle mka files. This will be great for people who mainly use the pseudo-gui version of this software.

@zc62 zc62 changed the title from Feature request: autoload subtitles tracks in mka files to Feature request: autoload subtitle tracks in mka files Nov 20, 2017

@zc62

This comment has been minimized.

Contributor

zc62 commented Nov 26, 2017

I made up a script to work on this feature.

@kevmitch

This comment has been minimized.

Member

kevmitch commented Dec 7, 2017

In this and the previous bug, I never saw a sample file. I just made an mka by stripping out the video from a DVD rip in mkvtoolnix and the subtitlles just worked. Or is this something about trying to be clever about which subtitle to select? Is the script sufficient? How does mpv handle mka differently than mkv and why?

@kevmitch kevmitch added the info-needed label Dec 7, 2017

@zc62

This comment has been minimized.

Contributor

zc62 commented Dec 7, 2017

@kevmitch
OK I didn't make it clear. I know when a single mka file is opened by mpv, all audio and subtitle tracks in this mka file are loaded properly. The problem occurs when the mka file is loaded by --audio-file-auto option. You can try keep that mka file you had, leave only the video track in the mkv file and open the mkv file with --audio-file-auto=fuzzy and --sub-auto=fuzzy. My observation is that audio tracks in the mka file are loaded correctly but no subtitle tracks can be seen.

The script is not perfect, because the order of lua script execution and external-file loading in mpv cannot be predicted. My script manually adds these mka files as sub-files. For some unknown reasons, if my script is executed before mpv loading the mka file as audio-files (driven by audio-file-auto), the mka file won't be loaded as audio-files anymore. Then in my script I add them back. If my script is executed later, then everything is okay. So one will observe inconsistent audio track orderings between different runs. Sometimes correct (same ordering as without my script) but sometimes wrong.

@zc62 zc62 changed the title from Feature request: autoload subtitle tracks in mka files to Feature request: autoload subtitle tracks in mka files when opening a mkv file with --audio-file-auto and --sub-auto Dec 7, 2017

@kevmitch

This comment has been minimized.

Member

kevmitch commented Dec 7, 2017

Does hooking file-loaded instead of start-file work any better?

It looks like mpv will fuzzy load an .mka file as audio and an .mks file as subtitles but not the other way around. So the "solution" would be to try and fuzzy load any similarly named .mkX as audio and / or subtitles. Could that have surprising consequences?

@zc62

This comment has been minimized.

Contributor

zc62 commented Dec 7, 2017

Yes, file-loaded works better. Thanks.

There are still minor bugs (depending on which flag I am using when execute sub-add). I think the auto flag is the one closest to correct, because at least it won't break sid=no (subtitle auto-load, but no auto-selection). But in this case even sid equals some language codes, nothing will be auto-selected when we only have subtitles from the mka file. Or, when there are other external subtitle files, the auto flag won't select subtitles in the mka file while slang would do so. Other two flags (select and cached), in contrary, give subtitles in the mka file the highest priority, even when slang should select another external sub-file.

I think load every mkX as audio and sub-files should work, and may be easy to implement. But maybe it can be more efficient? I saw the demuxer could correctly show all of the tracks in the mka file when it was pulled by --audio-file-auto. Will it be more straightforward to add the subtitle tracks to track-list at that time, if they fulfill the --sub-auto requirement? slang and sid auto-selection take place afterwards, so that the auto-selection should work perfectly.

@wm4

This comment has been minimized.

Contributor

wm4 commented Dec 7, 2017

I think what you want is that it loads all streams from autoloaded files?

Could be done by removing the filter argument from mp_add_external_file() and everything it calls.

@zc62

This comment has been minimized.

Contributor

zc62 commented Dec 7, 2017

Yes, exactly.

@wm4

This comment has been minimized.

Contributor

wm4 commented Dec 7, 2017

See #5192.

@zc62

This comment has been minimized.

Contributor

zc62 commented Dec 7, 2017

Tested. It works!

@kevmitch kevmitch closed this in 80d43ee Dec 8, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment