lisamelton / video_transcoding

Tools to transcode, inspect and convert videos.
MIT License
2.39k stars 160 forks source link

Copy subtitle description (title) when --add-subtitle is used #271

Open klogg416 opened 5 years ago

klogg416 commented 5 years ago

Hi @donmelton I have an official question! When adding (not burning) subtitles, is there a way to have the "title" field copied as well? I don't see it in the help or readme. With anime in particular you often have multiple English subtitles: studio, improved Disney re-release, and "signs" with subs only for relevant in-movie signs. Using --add-subtitle all works as expected but the detailed names aren't copied over so it isn't clear which English sub is which.

Is there a way to do this today, or can I submit a feature request to copy existing subtitle descriptions when the --add-subtitle switch is called?

Thanks!

Here are mediainfo examples.

Source:

Text #1
ID                                       : 4
Format                                   : PGS
Muxing mode                              : zlib
Codec ID                                 : S_HDMV/PGS
Codec ID/Info                            : Picture based subtitle format used on BDs/HD-DVDs
Duration                                 : 2 h 2 min
Bit rate                                 : 22.7 kb/s
Count of elements                        : 2012
Stream size                              : 19.9 MiB (0%)
Title                                    : Ghibli
Language                                 : English
Default                                  : No
Forced                                   : No

Text #2
ID                                       : 5
Format                                   : PGS
Muxing mode                              : zlib
Codec ID                                 : S_HDMV/PGS
Codec ID/Info                            : Picture based subtitle format used on BDs/HD-DVDs
Duration                                 : 1 h 59 min
Bit rate                                 : 25.8 kb/s
Count of elements                        : 1778
Stream size                              : 22.1 MiB (0%)
Title                                    : Disney
Language                                 : English
Default                                  : Yes
Forced                                   : Yes

Text #3
ID                                       : 6
Format                                   : PGS
Muxing mode                              : zlib
Codec ID                                 : S_HDMV/PGS
Codec ID/Info                            : Picture based subtitle format used on BDs/HD-DVDs
Duration                                 : 2 h 1 min
Bit rate                                 : 28.2 kb/s
Count of elements                        : 2178
Stream size                              : 24.4 MiB (0%)
Title                                    : SDH
Language                                 : English
Default                                  : No
Forced                                   : No

and transcoded:

Text #1
ID                                       : 4
Format                                   : PGS
Codec ID                                 : S_HDMV/PGS
Codec ID/Info                            : Picture based subtitle format used on BDs/HD-DVDs
Duration                                 : 2 h 4 min
Language                                 : English
Default                                  : No
Forced                                   : No

Text #2
ID                                       : 5
Format                                   : PGS
Codec ID                                 : S_HDMV/PGS
Codec ID/Info                            : Picture based subtitle format used on BDs/HD-DVDs
Duration                                 : 2 h 1 min
Language                                 : English
Default                                  : No
Forced                                   : No

Text #3
ID                                       : 6
Format                                   : PGS
Codec ID                                 : S_HDMV/PGS
Codec ID/Info                            : Picture based subtitle format used on BDs/HD-DVDs
Duration                                 : 2 h 1 min
Language                                 : English
Default                                  : No
Forced                                   : No
lisamelton commented 5 years ago

@klogg416 Good question, Kyle! Unfortunately, HandBrakeCLI doesn't have an API to set the title/name of a subtitle. And while I might be able to make this work with mkvpropedit for MKV output by post-processing, I'm not sure if that's even possible for MP4 output because the mp4track tool I which I use for media queries may not allow that.

Let me look into it and I'll see what I can do. But don't get your hopes up.

In the meantime, you should open an issue on the HandBrake project and request an API for this.

klogg416 commented 5 years ago

@donmelton As far as reasons go, that is a convincing one. Thanks for the considered reply, I will get on it with team HandBrake.

In the interim a quick check the mkvpropedit documentation shows me that it can edit without re-writing the entire file, so that gives me an easy way to update the handful of impacted files today. Thanks for pointing me in that direction Don!

lisamelton commented 5 years ago

@klogg416 No problem and thanks for filing that issue!

khaosx commented 5 years ago

@klogg416

This is part of my wrapper script (Yo dawg, I heard you liked wrappers, so I built a script to wrap the wrapper gem that wraps the wrapper app for FFmpeg). It changes the title of whatever movie I'm encoding, if the existing title doesn't match the file name. You can easily do the same with other properties. Hope this helps!

if [ "$strFilename" != "$strMIName" ]; then
    mkvpropedit "$strTheFile" --edit info --set "title=$strFilename"
fi
klogg416 commented 5 years ago

Two fun updates, request #197 exists for the GUI version and touches on the need. I created #1965 referencing #197 but calling specifically for an API in HandBrakeCLI.

edit: github helpfully smart linked for me, but to this project instead of HandBrake.

klogg416 commented 5 years ago
if [ "$strFilename" != "$strMIName" ]; then
  mkvpropedit "$strTheFile" --edit info --set "title=$strFilename"
fi

@khaosx that is super helpful to start from as I dig into mkvpropedit, thank you!! And I appreciate the deep, deep meta recursion, and look forward to the troubleshoot efforts required when you hand off layers of wrappers to a slightly less technical friend. :-)

lisamelton commented 5 years ago

@khaosx @klogg416 You guys are amazing. What a bunch of geeks! :)

khaosx commented 5 years ago

I have added this to my starter, to keep track of what version of the gem managed the encoding:

mkvpropedit "$strTheFile" --edit info --set "muxing-application=vtp_0.25"

(vtp = video transcoding project)

This shows up in media info as:

Writing library : vtp_0.25 / Lavf58.20.100

while leaving this correct:

Writing application : HandBrake 1.2.0 2018122300

At some point, I'll start tracking what changes I made to the script and tie those to Don's versions.

EDIT:

And then my new love affair with DevOps kicked in, and I realized that I can set up a continuous delivery pipeline by setting the server to find 15 movies a night that don't meet the minimum version, re-encoding the masters, and auto-replacing them in the library.

Shortly after that thought, I hit myself really hard in the face with a hammer to shut that thought down before things got out of hand...

lisamelton commented 5 years ago

@khaosx I never noticed that attribute changed by just using mkvpropedit. Nice catch! You're obviously paying attention to the details.

Oooh, automatic selection for re-transcoding, eh? Clever! You are living in the Star Trek future now. And that's gotta be simpler than my excruciatingly manual method (which I will describe one day when I'm not in a hurry).

But stay away from those hammers! :)