Skip to content
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

Add sub-text-all property #12810

Closed
karelrooted opened this issue Nov 5, 2023 · 11 comments
Closed

Add sub-text-all property #12810

karelrooted opened this issue Nov 5, 2023 · 11 comments
Labels

Comments

@karelrooted
Copy link
Contributor

karelrooted commented Nov 5, 2023

Currently there has property sub-text https://mpv.io/manual/master/#command-interface-sub-text to observe the text of the current sub. It would be nice to have a similar property for the entire subtitle, possibly called sub-text-all

the usage of this feature may be to get the entire embedded subtitle and then translate it and add a translated subtitle track on the fly

Expected behavior of the wanted feature

add a sub-text-all property to return the current entire subtitle as text

@po5
Copy link
Contributor

po5 commented Nov 5, 2023

Not possible for many files to get all subtitle lines without parsing through the entire file, as the data can be scattered across the file near each video/audio data chunk. You'll notice that ffmpeg can extract some subtitles near instantly and others will take a while.

@llyyr
Copy link
Contributor

llyyr commented Nov 5, 2023

the usage of this feature may be get the entire embedded subtitle and then translate it and add a translated subtitle track

This is completely out of scope for mpv, you're looking to use something like Aegisub for .ass files, and if it's not an .ass file then you should convert it with ffmpeg.

@karelrooted
Copy link
Contributor Author

the usage of this feature may be get the entire embedded subtitle and then translate it and add a translated subtitle track

This is completely out of scope for mpv, you're looking to use something like Aegisub for .ass files, and if it's not an .ass file then you should convert it with ffmpeg.

when try to add bilingual subtitle track on the fly with embedded subtitle, currently have to use ffmpeg to get the entire subtitle, it seems unoptimized when mpv is already loading the file

@Dudemanguy
Copy link
Member

mpv has the file loaded, but it won't read the entire thing at once of course. It only reads what is necessary for playback. For mpv to do what you want, it would have to read the entire file from beginning to end again which is no different from just using ffmpeg to read the whole thing.

@Dudemanguy Dudemanguy added the priority:on-ice may be revisited later label Nov 5, 2023
@karelrooted
Copy link
Contributor Author

mpv has the file loaded, but it won't read the entire thing at once of course. It only reads what is necessary for playback. For mpv to do what you want, it would have to read the entire file from beginning to end again which is no different from just using ffmpeg to read the whole thing.

copy that

@karelrooted karelrooted closed this as not planned Won't fix, can't repro, duplicate, stale Nov 5, 2023
@christoph-heinrich
Copy link
Contributor

christoph-heinrich commented Nov 5, 2023

What if the property only returns the subtitle lines that mpv already knows about?
That would make my script much simpler, faster and more reliable. Currently it walks through the subtitle lines with sub-step and then reads sub-start, sub-end and sub-text.

@Dudemanguy
Copy link
Member

mpv only holds onto a couple of subtitle packets at a time. Anything older gets discarded, so I don't think there's any way for this other than reading through all the packets again which I'm not sure we want to do.

@christoph-heinrich
Copy link
Contributor

christoph-heinrich commented Nov 5, 2023

Well we could just not discard them 🙃 I don't think the memory overhead for some text would be a problem.

@Lypheo
Copy link
Contributor

Lypheo commented Nov 5, 2023

Anything older gets discarded

Where? Afaict all events are buffered unless the ASS_Track is flushed which only happens when we reset the sub track.

@Dudemanguy
Copy link
Member

I thought libass internally discarded stuff after a while. But sure I could be wrong. Feel free to send a patch if it's not so bad.

@karelrooted
Copy link
Contributor Author

karelrooted commented Nov 12, 2023

this commit added a sub-text-all, secondary-sub-text-all property

I'm not a experience c coder, so the code may need some clean up to conform to mpv's code standard, but it works on my local bilingual player (not production tested though, because I'm the only user who use it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants