mdhiggins / sickbeard_mp4_automator

Automatically convert video files to a standardized format with metadata tagging to create a beautiful and uniform media library
MIT License
1.52k stars 201 forks source link

Subtitle marked as default #1707

Closed SenorSmartyPants closed 6 months ago

SenorSmartyPants commented 6 months ago

Describe the bug I'm doing several things, one is striping extra subtitle languages out. I'm leaving english (2 tracks) neither are marked default in the source, but the first is marked default in the output. How do I disable this? (VLC shows the default subtitles when I don't need it to)

autoProcess.ini settings

[Subtitle]
codec = srt, subrip, ass
codec-image-based =
languages = eng
default-language = eng
include-original-language = True
first-stream-of-language = False
encoding =
burn-subtitles = False
burn-dispositions =
embed-subs = True
embed-image-subs = False
embed-only-internal-subs = False
filename-dispositions = forced
ignore-embedded-subs = False
ignored-dispositions =
force-default = False
unique-dispositions = False
attachment-codec =
remove-bitstream-subs = False

Log files

2024-03-11 12:59:33 - MANUAL - INFO - Manual processor started.
2024-03-11 12:59:33 - MANUAL - INFO - Python 64-bit 3.11.6 (main, Oct 13 2023, 15:52:55) [GCC 13.1.1 20230722].
2024-03-11 12:59:33 - MANUAL - INFO - Guessit version: 3.8.0.
2024-03-11 12:59:33 - MANUAL - INFO - /usr/local/sma/venv/bin/python3
2024-03-11 12:59:33 - MANUAL - INFO - Loading config file /usr/local/sma/config/autoProcess.ini.
2024-03-11 12:59:33 - MANUAL - INFO - No-delete enabled
2024-03-11 12:59:34 - MANUAL - INFO - Initiating custom validation method.
2024-03-11 12:59:34 - MANUAL - INFO - Audio Track: eng eac3 6 channels
2024-03-11 12:59:34 - MANUAL - INFO - Valid audio track count is 1.
2024-03-11 12:59:34 - MANUAL - INFO - Non AC3 5.1 found, convert to AC3. Modified pool of audio codecs is ['ac3'].
2024-03-11 12:59:34 - MANUAL - INFO - Processing file /storage/media/Videos/TV/The Mandalorian/Season 3/The Mandalorian 3x01 [WEBDL-1080p x264][EAC3 Atmos 5.1][DSNP][-NTb] - Chapter 17.mkv
2024-03-11 12:59:34 - MANUAL - INFO - Input Data
2024-03-11 12:59:34 - MANUAL - INFO - {
    "format": "matroska,webm",
    "format-fullname": "Matroska / WebM",
    "video": {
        "index": 0,
        "codec": "h264",
        "bitrate": 6007010,
        "pix_fmt": "yuv420p",
        "profile": "high",
        "fps": 24.0,
        "framedata": {
            "pix_fmt": "yuv420p",
            "color_space": "bt709",
            "color_primaries": "bt709",
            "color_transfer": "bt709",
            "tags": {
                "timecode": "00:00:00:00"
            },
            "side_data_list": [
                {
                    "side_data_type": "SMPTE 12-1 timecode",
                    "timecodes": [
                        {
                            "value": "00:00:00:00"
                        }
                    ]
                }
            ]
        },
        "dimensions": "1920x1080",
        "level": 4.0,
        "field_order": "progressive"
    },
    "audio": [
        {
            "index": 1,
            "codec": "eac3",
            "bitrate": 768000,
            "channels": 6,
            "samplerate": 48000,
            "language": "eng",
            "disposition": "+default-dub+original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions"
        }
    ],
    "subtitle": [
        {
            "index": 2,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "eng"
        },
        {
            "index": 3,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced+hearing_impaired-visual_impaired-captions",
            "language": "eng"
        },
        {
            "index": 4,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "ces"
        },
        {
            "index": 5,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "dan"
        },
        {
            "index": 6,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "deu"
        },
        {
            "index": 7,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "ell"
        },
        {
            "index": 8,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "spa"
        },
        {
            "index": 9,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "spa"
        },
        {
            "index": 10,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "fin"
        },
        {
            "index": 11,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "fra"
        },
        {
            "index": 12,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "hun"
        },
        {
            "index": 13,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "ita"
        },
        {
            "index": 14,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "jpn"
        },
        {
            "index": 15,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "kor"
        },
        {
            "index": 16,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "nld"
        },
        {
            "index": 17,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "nor"
        },
        {
            "index": 18,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "pol"
        },
        {
            "index": 19,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "por"
        },
        {
            "index": 20,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "por"
        },
        {
            "index": 21,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "ron"
        },
        {
            "index": 22,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "slk"
        },
        {
            "index": 23,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "swe"
        },
        {
            "index": 24,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "tur"
        },
        {
            "index": 25,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "zho"
        },
        {
            "index": 26,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "zho"
        }
    ],
    "attachment": []
}
2024-03-11 12:59:34 - MANUAL - INFO - Reading video stream.
2024-03-11 12:59:34 - MANUAL - INFO - Video codec detected: h264.
2024-03-11 12:59:34 - MANUAL - INFO - Pix Fmt: yuv420p.
2024-03-11 12:59:34 - MANUAL - INFO - Profile: high.
2024-03-11 12:59:34 - MANUAL - INFO - Video codec parameters None.
2024-03-11 12:59:34 - MANUAL - INFO - Creating copy video stream from source stream 0.
2024-03-11 12:59:34 - MANUAL - INFO - Reading audio streams.
2024-03-11 12:59:34 - MANUAL - INFO - The following stream indexes have been identified as being copies: [] [stream-codec-combinations].
2024-03-11 12:59:34 - MANUAL - INFO - Audio detected for stream 1 - eac3 eng 6 channel.
2024-03-11 12:59:34 - MANUAL - INFO - Creating ac3 audio stream from source stream 1.
2024-03-11 12:59:34 - MANUAL - INFO - Found 0 streams that can be removed from the output file since they will be duplicates [stream-codec-combinations].
2024-03-11 12:59:34 - MANUAL - INFO - Final sorting:
2024-03-11 12:59:34 - MANUAL - INFO - ['0->0']
2024-03-11 12:59:34 - MANUAL - INFO - Final sorting:
2024-03-11 12:59:34 - MANUAL - INFO - ['0->0']
2024-03-11 12:59:34 - MANUAL - INFO - Default audio stream set to eng ac3 6 channel stream [audio-default-sorting: ['channels.d', 'map', 'd.comment']].
2024-03-11 12:59:34 - MANUAL - INFO - Reading subtitle streams.
2024-03-11 12:59:34 - MANUAL - INFO - Subtitle detected for stream 2 - subrip eng.
2024-03-11 12:59:35 - MANUAL - INFO - Stream 2 is text-based subtitle for codec subrip.
2024-03-11 12:59:35 - MANUAL - INFO - Creating copy subtitle stream from source stream 2.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 3 - subrip eng.
2024-03-11 12:59:35 - MANUAL - INFO - Stream 3 is text-based subtitle for codec subrip.
2024-03-11 12:59:35 - MANUAL - INFO - Creating copy subtitle stream from source stream 3.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 4 - subrip ces.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 5 - subrip dan.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 6 - subrip deu.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 7 - subrip ell.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 8 - subrip spa.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 9 - subrip spa.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 10 - subrip fin.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 11 - subrip fra.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 12 - subrip hun.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 13 - subrip ita.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 14 - subrip jpn.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 15 - subrip kor.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 16 - subrip nld.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 17 - subrip nor.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 18 - subrip pol.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 19 - subrip por.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 20 - subrip por.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 21 - subrip ron.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 22 - subrip slk.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 23 - subrip swe.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 24 - subrip tur.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 25 - subrip zho.
2024-03-11 12:59:35 - MANUAL - INFO - Subtitle detected for stream 26 - subrip zho.
2024-03-11 12:59:35 - MANUAL - INFO - Scanned for external subtitles and found 0 results in your approved languages.
2024-03-11 12:59:35 - MANUAL - INFO - Final sorting:
2024-03-11 12:59:35 - MANUAL - INFO - ['0->0', '1->1']
2024-03-11 12:59:35 - MANUAL - INFO - Output Data
2024-03-11 12:59:35 - MANUAL - INFO - {
    "source": [
        "/storage/media/Videos/TV/The Mandalorian/Season 3/The Mandalorian 3x01 [WEBDL-1080p x264][EAC3 Atmos 5.1][DSNP][-NTb] - Chapter 17.mkv"
    ],
    "format": "mkv",
    "video": {
        "codec": "copy",
        "map": 0,
        "bitrate": 5710.466149999999,
        "crf": -1,
        "maxrate": null,
        "bufsize": null,
        "level": 0.0,
        "profile": null,
        "preset": null,
        "pix_fmt": null,
        "field_order": "progressive",
        "width": null,
        "filter": null,
        "params": null,
        "framedata": null,
        "bsf": null,
        "debug": "video",
        "title": ""
    },
    "audio": [
        {
            "map": 1,
            "codec": "ac3",
            "channels": 6,
            "bitrate": 768,
            "profile": null,
            "quality": 0,
            "filter": null,
            "samplerate": null,
            "sampleformat": "",
            "language": "eng",
            "disposition": "+default-dub+original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "bsf": null,
            "debug": "audio",
            "title": ""
        }
    ],
    "subtitle": [
        {
            "map": 2,
            "codec": "copy",
            "language": "eng",
            "disposition": "+default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "debug": "subtitle.embed-subs",
            "title": null
        },
        {
            "map": 3,
            "codec": "copy",
            "language": "eng",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced+hearing_impaired-visual_impaired-captions",
            "debug": "subtitle.embed-subs",
            "title": "sdh"
        }
    ],
    "attachment": []
}
SenorSmartyPants commented 6 months ago
[Subtitle]
default-language = eng

It seems like the above setting is the problem. From the wiki descript If subtitle stream language is undefined, assumed this language I thought it would just set the language flag of subtitle streams that were unknown to eng. But it is (also?) setting the disposition default flag to true.

mdhiggins commented 6 months ago

Not a bug, just intended behavior. Most players only will display subtitles for 'forced' subtitles by default so this is VLC being different Currently the script will attempt to figure out a default subtitle if one isn't present if you have a default language specified, this feature doesn't trigger if there's no default language which is why you're changing the behavior by changing the default-language option

8041e2957c8f328564e50e9a703f013174d17b06

This adds a new option force-default which is set to True, setting this to false will disable this behavior for you

VampiricAlien commented 6 months ago

@mdhiggins I have a question about subtitles names (saves opening new issue) I've looked at the wiki but wasn't able to find an answer. How do I go about making sure the script keep SDH (for Hearing Impaired) in the name without keeping the title as is? Could the script add SDH while renaming it if it was detected?

Before script: Description: SDH after script: not listed in VLC.

mdhiggins commented 6 months ago

It already marks the subtitle as "Hearing Impaired" in the title if the disposition is appropriately set

    # Get title for subtitle stream based on disposition
    def subtitleStreamTitle(self, stream, options, imageBased=False, path=None, tagdata=None):
        if streamTitle:
            try:
                customTitle = streamTitle(self, stream, options, imageBased=imageBased, path=path, tagdata=None)
                if customTitle is not None:
                    return customTitle
            except:
                self.log.exception("Custom streamTitle exception")

        if self.settings.keep_titles and stream.metadata.get('title'):
            return stream.metadata.get('title')

        output = ""
        disposition = stream.disposition
        for dispo in BaseCodec.DISPO_STRINGS:
            if disposition.get(dispo):
                output += "%s " % BaseCodec.DISPO_STRINGS[dispo]
        return output.strip() if output else None

The script should also infer the disposition from the existing title if the title contains SDH even if the disposition metadata isn't appropriately set

If this isn't working then please open a new issue with some logs

VampiricAlien commented 6 months ago

It already marks the subtitle as "Hearing Impaired" in the title if the disposition is appropriately set

    # Get title for subtitle stream based on disposition
    def subtitleStreamTitle(self, stream, options, imageBased=False, path=None, tagdata=None):
        if streamTitle:
            try:
                customTitle = streamTitle(self, stream, options, imageBased=imageBased, path=path, tagdata=None)
                if customTitle is not None:
                    return customTitle
            except:
                self.log.exception("Custom streamTitle exception")

        if self.settings.keep_titles and stream.metadata.get('title'):
            return stream.metadata.get('title')

        output = ""
        disposition = stream.disposition
        for dispo in BaseCodec.DISPO_STRINGS:
            if disposition.get(dispo):
                output += "%s " % BaseCodec.DISPO_STRINGS[dispo]
        return output.strip() if output else None

The script should also infer the disposition from the existing title if the title contains SDH even if the disposition metadata isn't appropriately set

If this isn't working then please open a new issue with some logs

Was doing some testing and found that the issue was with Clean it, set to false the subtitle keeps SDH.

mdhiggins commented 6 months ago

This is probably because cleanit exports the subtitle to a file before merging it back in

You can add hearing_impaired to the filename-dispositions option to preserve this if you want to keep cleanit

mdhiggins commented 6 months ago

b53701d96a582bbea13fd8db81217c1978442737

This update has the cleanit extracted subtitles automatically include all disposition data since its just going to be reimported anyway, now you don't need to modify the filename-dispositions setting

VampiricAlien commented 6 months ago

Good to know, thank you. Does this also include SMA as well?

mdhiggins commented 6 months ago

What?

VampiricAlien commented 6 months ago

Sonarr SMA mod

mdhiggins commented 6 months ago

Next time it auto rebuilds or you can just use SMA_UPDATE and restart the container to pull the latest