Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Archive: enhance mkv tracks metadata #26

Closed
hekmon opened this issue Apr 25, 2022 · 5 comments
Closed

Archive: enhance mkv tracks metadata #26

hekmon opened this issue Apr 25, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@hekmon
Copy link
Contributor

hekmon commented Apr 25, 2022

Hello,

Just wondering why subtitles have their title set to human readable locale but not the their metadata language field ? (which is even more important for players to automatically select the right one for their user)

You do set the language field for video and audio. Why not subtitles ?

It seems to me that your actual locales would be valid values for mkv (from what I see in mkvtoolnix-gui).

Anyway, thank you for your work this software has been working flawlessly so far !

@hekmon
Copy link
Contributor Author

hekmon commented Apr 25, 2022

I guess we could extend this bug report to the language metadata values set for audio/video track (here and here).

You set it to the human readable form but ffmpeg expects for matroska a particular encoding (ISO 639-2/B).

So I guess the correct line could look like something like this if you want to keep the human readable form:

// video
metadata = append(metadata, fmt.Sprintf("-metadata:s:v:%d", i), fmt.Sprintf("language=%s", locale)
metadata = append(metadata, fmt.Sprintf("-metadata:s:v:%d", i), fmt.Sprintf("title=%s", utils.LocaleLanguage(locale))
// audio
metadata = append(metadata, fmt.Sprintf("-metadata:s:a:%d", i), fmt.Sprintf("language=%s", locale)
metadata = append(metadata, fmt.Sprintf("-metadata:s:a:%d", i), fmt.Sprintf("title=%s", utils.LocaleLanguage(locale))
// subtitle
metadata = append(metadata, fmt.Sprintf("-metadata:s:s:%d", i), fmt.Sprintf("language=%s", locale)
metadata = append(metadata, fmt.Sprintf("-metadata:s:s:%d", i), fmt.Sprintf("title=%s", utils.LocaleLanguage(locale))

If ffmpeg accepts the current form of locale values (or another helper could produce valid values based on the current ones).

@hekmon
Copy link
Contributor Author

hekmon commented Apr 26, 2022

Commit 06a5414 seems to work fine, cheers !
image

The last thing a bit annoying with subtitle is that without any particular options, the first track will be marked as default which will not necessarily be the one the user reads. I saw you try to detect the user local, it could be a nice addition to set the track language corresponding to the user local as default ?

In case local is not detected or if detected but no corresponding subtitle track can be found, you can still add the -default_mode infer_no_subs flag to ffmpeg in order to not mark any default subtitle track.

Thanks again for your work.

Edit: just reread the doc; you could actually always leave the flag -default_mode infer_no_subs on as it will not interfere if you manually set a default subtitle track based on local and act as a fail safe if no default is explicitly defined.

@bytedream
Copy link
Member

bytedream commented Apr 27, 2022

Fixed in newest commit 0c92fc0, but I had to use -disposition:s:0 0 instead of -default_mode infer_no_subs since this didn't work for some reason (and -disposition is supported by older ffmpeg versions).

@hekmon hekmon changed the title Archive: subtitles language not set Archive: enhance mkv tracks metadata Apr 27, 2022
@hekmon
Copy link
Contributor Author

hekmon commented Apr 27, 2022

I can confirm 0c92fc0 works fine on my side, thanks !

@bytedream
Copy link
Member

bytedream commented Apr 28, 2022

I saw you try to detect the user local, it could be a nice addition to set the track language corresponding to the user local as default ?

This is already implemented since v2.0.1, I totally forgot about that lol xd. Just set the environment variable SORT_SUBTITLES=1 before executing and the subtitles should be sorted.

@bytedream bytedream added enhancement New feature or request cli labels May 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants