Allow use of original subtitle track title as a fallback if the resulting output title is empty
See original GitHub issueI import a number of files where the original subtitle track title contains some important information that I’d like to preserve. The most common example I have is “Signs and Songs” subtitles intended for use when watching dubbed anime.
“Signs and Songs” subtitle tracks are solely identified by their title, meaning they do not have a unique ffmpeg
disposition that could be used to distinguish them. Additionally, there isn’t really a consistent naming scheme (most encoders title the track Signs and Songs
, but I’ve seen Signs
, S/S
, Signs / Songs
, etc).
I know the keep-titles
option exists, but I’d like to maintain clean title generation for audio tracks and for subtitle tracks that have a distinguishing ffmpeg
disposition (such as commetary/forced).
There’s probably a couple ways to address this, but I think the easiest would be to include a config option under the Subtitle category that allows the output track title to fallback to its old value if the new one would be an empty string. I suppose this option could also be placed under Metadata, but I don’t believe I’ve ever seen an audio track outputted without a title, only subtitles.
default
is an interesting edge case, because while it doesn’t trigger a change in the output title like commentary
/forced
do, it also (for this use case) shouldn’t trigger a fallback to the input track title. Meaning that if the default english subtitle track is titled “English Subtitles”, the better outcome is to result in a blank output title instead of falling back, as “English Subtitles” doesn’t provide any important information unlike “Signs and Songs”. Best approach is probably to have a track marked as default
always write an empty title and ignore the what the config says about falling back to the input title (unless keep-titles = true
, ofc)
Quick mock up of how this would work with this new option called allow-title-fallback
:
keep-titles = false
allow-title-fallback = false
input subtitles:
{
"language": "eng",
"disposition": "+default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
"title": "English Subtitles"
},
{
"language": "eng",
"disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
"title": "Signs and Songs"
},
{
"language": "eng",
"disposition": "-default-dub-original-comment-lyrics-karaoke+forced-hearing_impaired-visual_impaired-captions",
"title": "Forced Foreign Language"
}
output subtitles:
{
"language": "eng",
"disposition": "+default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
"title": null
},
{
"language": "eng",
"disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
"title": null
},
{
"language": "eng",
"disposition": "-default-dub-original-comment-lyrics-karaoke+forced-hearing_impaired-visual_impaired-captions",
"title": "Forced / Forced"
}
keep-titles = true
allow-title-fallback = false
input subtitles:
{
"language": "eng",
"disposition": "+default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
"title": "English Subtitles"
},
{
"language": "eng",
"disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
"title": "Signs and Songs"
},
{
"language": "eng",
"disposition": "-default-dub-original-comment-lyrics-karaoke+forced-hearing_impaired-visual_impaired-captions",
"title": "Forced Foreign Language"
}
output subtitles:
{
"language": "eng",
"disposition": "+default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
"title": "English Subtitles"
},
{
"language": "eng",
"disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
"title": "Signs and Songs"
},
{
"language": "eng",
"disposition": "-default-dub-original-comment-lyrics-karaoke+forced-hearing_impaired-visual_impaired-captions",
"title": "Forced Foreign Language"
}
(behavior I’m proposing)
keep-titles = false
allow-title-fallback = true
input subtitles:
{
"language": "eng",
"disposition": "+default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
"title": "English Subtitles"
},
{
"language": "eng",
"disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
"title": "Signs and Songs"
},
{
"language": "eng",
"disposition": "-default-dub-original-comment-lyrics-karaoke+forced-hearing_impaired-visual_impaired-captions",
"title": "Forced Foreign Language"
}
output subtitles:
{
"language": "eng",
"disposition": "+default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
"title": null
},
{
"language": "eng",
"disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
"title": "Signs and Songs"
},
{
"language": "eng",
"disposition": "-default-dub-original-comment-lyrics-karaoke+forced-hearing_impaired-visual_impaired-captions",
"title": "Forced / Forced"
}
The one edge case that can’t really be handled is where we have a titled subtitle track that probably should be marked as default, but isn’t. In this case we’d end up preserving a title where if allow-title-fallback
was false, would have been wiped. (i.e. if the “English Subtitles” track in the above examples wasn’t marked as default, its title would be preserved). However that’s probably the best outcome, as the goal of this configuration option is to provide a fallback when we don’t have any useful metadata to work with, so if subtitle tracks aren’t marked properly the best the script could do is use the old track title.
I know this is a bit of an edge case, but I think it would help a lot of people who use this script for libraries that include Anime or other foreign media that include Signs and Songs
.
Issue Analytics
- State:
- Created a year ago
- Comments:12 (4 by maintainers)
Top GitHub Comments
Actually this is probably what you meant
60f2b42c0baf069385c203703c5d60e6e685ecdb
DISPO_STRING dict there for you
You can also just return None to use the build in title function instead of recreating it
I’m feeding mine to Jellyfin which does the same preferences, except when it tries to talk DLNA. Sometimes it’ll just pick whatever track it wants to do, no matter what I tell it - but I think that’s a problem with the dispositions (you’ll see below). I’m the sole user for my stuff, so I’m trying to strip everything I don’t need, and burn in subtitles where I do need them - then no matter what the playback device it’s a single file exactly how I want it.
The problem I have is the dispositions of the streams in the media I have:
As you can see, everything is default, so I’ve got no chance.