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.5k stars 206 forks source link

Convert Surround to AC3 5.1, keep original; on reprocess creates another AC3 from original #1681

Closed SenorSmartyPants closed 6 months ago

SenorSmartyPants commented 9 months ago

Is there a way with current settings to avoid the duplication in issue title?

My goal is to convert all surround streams to AC3, leave stereo streams alone, and keep the original surround. I want to keep the original surround in case I get my audio system upgraded to support more codecs.

But every time I run I get another AC3 stream. I'm currently testing configs to get things just right for my library, but I can see running SMA over my library again when I have another conversion need.

I'm up for coding custom functions if that is the only way to do this.

SenorSmartyPants commented 9 months ago

I enabled this setting stream-codec-combinations = ac3:eac3

And that seemed like it should do what I want, but failed with an error and still tried to convert EAC3 to AC3 again (log from second run).

Manual processor started. Python 64-bit 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]. Guessit version: 3.7.1. /usr/local/sma/venv/bin/python3 Loading config file /usr/local/sma/config/autoProcess.ini. Processing file /storage/media/Videos/TV/Physical/Season 3/Physical 3x05 [WEBDL-720p h264][EAC3 Atmos 5.1][ATVP][-NTb] - Like Crazy.mkv Input Data { "format": "matroska,webm", "format-fullname": "Matroska / WebM", "video": { "index": 0, "codec": "h264", "bitrate": 2805050, "pix_fmt": "yuv420p", "profile": "high", "fps": 23.976023976023978, "framedata": { "pix_fmt": "yuv420p", "color_space": "bt709", "color_primaries": "bt709", "color_transfer": "bt709" }, "dimensions": "1356x678", "level": 3.2, "field_order": "progressive" }, "audio": [ { "index": 1, "codec": "ac3", "bitrate": 640000, "channels": 6, "samplerate": 48000, "language": "eng", "disposition": "+default-dub+original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions" }, { "index": 2, "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": 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": "eng" }, { "index": 5, "codec": "subrip", "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions", "language": "spa" }, { "index": 6, "codec": "subrip", "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions", "language": "spa" } ], "attachment": [] } Reading video stream. Video codec detected: h264. Pix Fmt: yuv420p. Profile: high. Video codec parameters None. Creating copy video stream from source stream 0. Reading audio streams. The following stream indexes have been identified as being copies: [[1, 2]] [stream-codec-combinations]. Audio detected for stream 1 - ac3 eng 6 channel. Creating copy audio stream from source stream 1. Audio detected for stream 2 - eac3 eng 6 channel. Creating ac3 audio stream from source stream 2. Copying audio stream from source stream 2 format eac3 [audio-copy-original]. Unable to generate options, unexpected exception occurred. Traceback (most recent call last): File "/usr/local/sma/resources/mediaprocessor.py", line 153, in process options, preopts, postopts, ripsubopts, downloaded_subs = self.generateOptions(inputfile, info=info, original=original, tagdata=tagdata) File "/usr/local/sma/resources/mediaprocessor.py", line 1132, in generateOptions self.purgeDuplicateStreams(acombinations, audio_settings, info, self.settings.acodec, self.settings.ua) File "/usr/local/sma/resources/mediaprocessor.py", line 611, in purgeDuplicateStreams self.duplicateStreamSort(same_channel_options, info) File "/usr/local/sma/resources/mediaprocessor.py", line 633, in duplicateStreamSort options.sort(key=lambda x: x['bitrate'], reverse=True) File "/usr/local/sma/resources/mediaprocessor.py", line 633, in options.sort(key=lambda x: x['bitrate'], reverse=True) KeyError: 'bitrate' There was an error processing file /storage/media/Videos/TV/Physical/Season 3/Physical 3x05 [WEBDL-720p h264][EAC3 Atmos 5.1][ATVP][-NTb] - Like Crazy.mkv, no output data received

mdhiggins commented 9 months ago

Looks like the source bitrate wasn't being passed to the sorter when using the copy original option unintentionally which would cause the sorter to fail

See if this fixes 80e9ee6778f927a5542a9439060d59befbed80a5

SenorSmartyPants commented 9 months ago

That fixes the crashing error. But I'm still not getting the behavior I want from the first comment.

Now on the second run, audio streams get deleted and I'm back with just 1 AC3 audio track.

> abc@e0c92c929235:/usr/local/sma/venv/bin$ ./python3 /usr/local/sma/manual.py -a -i /storage/media/Videos/TV/Physical/Season\ 3/Physical\ 3x05\ \[WEBDL-720p\ h264\]\[EAC3\ Atmos\ 5.1\]\[ATVP\]\[-NTb\]\ -\ Like\ Crazy.mkv
Manual processor started.
Python 64-bit 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0].
Guessit version: 3.7.1.
/usr/local/sma/venv/bin/python3
Loading config file /usr/local/sma/config/autoProcess.ini.
Processing file /storage/media/Videos/TV/Physical/Season 3/Physical 3x05 [WEBDL-720p h264][EAC3 Atmos 5.1][ATVP][-NTb] - Like Crazy.mkv
Input Data
{
    "format": "matroska,webm",
    "format-fullname": "Matroska / WebM",
    "video": {
        "index": 0,
        "codec": "h264",
        "bitrate": 2805050,
        "pix_fmt": "yuv420p",
        "profile": "high",
        "fps": 23.976023976023978,
        "framedata": {
            "pix_fmt": "yuv420p",
            "color_space": "bt709",
            "color_primaries": "bt709",
            "color_transfer": "bt709"
        },
        "dimensions": "1356x678",
        "level": 3.2,
        "field_order": "progressive"
    },
    "audio": [
        {
            "index": 1,
            "codec": "ac3",
            "bitrate": 640000,
            "channels": 6,
            "samplerate": 48000,
            "language": "eng",
            "disposition": "+default-dub+original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions"
        },
        {
            "index": 2,
            "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": 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": "eng"
        },
        {
            "index": 5,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "spa"
        },
        {
            "index": 6,
            "codec": "subrip",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "language": "spa"
        }
    ],
    "attachment": []
}
Reading video stream.
Video codec detected: h264.
Pix Fmt: yuv420p.
Profile: high.
Video codec parameters None.
Creating copy video stream from source stream 0.
Reading audio streams.
The following stream indexes have been identified as being copies: [[1, 2]] [stream-codec-combinations].
Audio detected for stream 1 - ac3 eng 6 channel.
Creating copy audio stream from source stream 1.
Audio detected for stream 2 - eac3 eng 6 channel.
Creating ac3 audio stream from source stream 2.
Copying audio stream from source stream 2 format eac3 [audio-copy-original].
Found 2 streams that can be removed from the output file since they will be duplicates [stream-codec-combinations].
Final sorting:
['0->0']
Final sorting:
['0->0']
Default audio stream set to eng copy 6 channel stream [audio-default-sorting: ['channels.d', 'map', 'd.comment']].
Reading subtitle streams.
Subtitle detected for stream 3 - subrip eng.

Stream 3 is text-based subtitle for codec subrip.
Creating copy subtitle stream from source stream 3.
Subtitle detected for stream 4 - subrip eng.

Stream 4 is text-based subtitle for codec subrip.
Creating copy subtitle stream from source stream 4.
Subtitle detected for stream 5 - subrip spa.

Stream 5 is text-based subtitle for codec subrip.
Creating copy subtitle stream from source stream 5.
Subtitle detected for stream 6 - subrip spa.

Stream 6 is text-based subtitle for codec subrip.
Creating copy subtitle stream from source stream 6.
Scanned for external subtitles and found 0 results in your approved languages.
Final sorting:
['0->0', '1->1', '2->2', '3->3']
Output Data
{
    "source": [
        "/storage/media/Videos/TV/Physical/Season 3/Physical 3x05 [WEBDL-720p h264][EAC3 Atmos 5.1][ATVP][-NTb] - Like Crazy.mkv"
    ],
    "format": "mkv",
    "video": {
        "codec": "copy",
        "map": 0,
        "bitrate": 2670.12415,
        "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": "HD"
    },
    "audio": [
        {
            "map": 1,
            "codec": "copy",
            "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": "5.1 Channel (Original)"
        }
    ],
    "subtitle": [
        {
            "map": 3,
            "codec": "copy",
            "language": "eng",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "debug": "subtitle.embed-subs",
            "title": null
        },
        {
            "map": 4,
            "codec": "copy",
            "language": "eng",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced+hearing_impaired-visual_impaired-captions",
            "debug": "subtitle.embed-subs",
            "title": "SDH"
        },
        {
            "map": 5,
            "codec": "copy",
            "language": "spa",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "debug": "subtitle.embed-subs",
            "title": "Spanish (Latin America)"
        },
        {
            "map": 6,
            "codec": "copy",
            "language": "spa",
            "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
            "debug": "subtitle.embed-subs",
            "title": "Spanish (Spain)"
        }
    ],
    "attachment": []
}
Preopts
[
    "-fix_sub_duration"
]
Postopts
[
    "-threads",
    "0",
    "-metadata:g",
    "encoding_tool=SMA"
]
Starting conversion.

FFmpeg command:
======================
/usr/local/bin/ffmpeg -fix_sub_duration -i "/storage/media/Videos/TV/Physical/Season 3/Physical 3x05 [WEBDL-720p h264][EAC3 Atmos 5.1][ATVP][-NTb] - Like Crazy.mkv.2.original" -vcodec copy -map 0:0 -metadata:s:v title=HD -metadata:s:v handler_name=HD -c:a:0 copy -map 0:1 -metadata:s:a:0 "title=5.1 Channel (Original)" -metadata:s:a:0 "handler_name=5.1 Channel (Original)" -metadata:s:a:0 language=eng -disposition:a:0 +default-dub+original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions -c:s:0 copy -map 0:3 -metadata:s:s:0 title= -metadata:s:s:0 handler_name= -metadata:s:s:0 language=eng -disposition:s:0 -default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions -c:s:1 copy -map 0:4 -metadata:s:s:1 title=SDH -metadata:s:s:1 handler_name=SDH -metadata:s:s:1 language=eng -disposition:s:1 -default-dub-original-comment-lyrics-karaoke-forced+hearing_impaired-visual_impaired-captions -c:s:2 copy -map 0:5 -metadata:s:s:2 "title=Spanish (Latin America)" -metadata:s:s:2 "handler_name=Spanish (Latin America)" -metadata:s:s:2 language=spa -disposition:s:2 -default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions -c:s:3 copy -map 0:6 -metadata:s:s:3 "title=Spanish (Spain)" -metadata:s:s:3 "handler_name=Spanish (Spain)" -metadata:s:s:3 language=spa -disposition:s:3 -default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions -f matroska -threads 0 -metadata:g encoding_tool=SMA -y "/storage/media/Videos/TV/Physical/Season 3/Physical 3x05 [WEBDL-720p h264][EAC3 Atmos 5.1][ATVP][-NTb] - Like Crazy.mkv"
======================
[####################] 100%
/storage/media/Videos/TV/Physical/Season 3/Physical 3x05 [WEBDL-720p h264][EAC3 Atmos 5.1][ATVP][-NTb] - Like Crazy.mkv created.
{
    "input": "/storage/media/Videos/TV/Physical/Season 3/Physical 3x05 [WEBDL-720p h264][EAC3 Atmos 5.1][ATVP][-NTb] - Like Crazy.mkv.2.original",
    "input_extension": "original",
    "input_deleted": false,
    "output": "/storage/media/Videos/TV/Physical/Season 3/Physical 3x05 [WEBDL-720p h264][EAC3 Atmos 5.1][ATVP][-NTb] - Like Crazy.mkv",
    "output_extension": "mkv",
    "options": {
        "source": [
            "/storage/media/Videos/TV/Physical/Season 3/Physical 3x05 [WEBDL-720p h264][EAC3 Atmos 5.1][ATVP][-NTb] - Like Crazy.mkv.2.original"
        ],
        "format": "mkv",
        "video": {
            "codec": "copy",
            "map": 0,
            "bitrate": 2670.12415,
            "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": "HD"
        },
        "audio": [
            {
                "map": 1,
                "codec": "copy",
                "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": "5.1 Channel (Original)"
            }
        ],
        "subtitle": [
            {
                "map": 3,
                "codec": "copy",
                "language": "eng",
                "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
                "debug": "subtitle.embed-subs",
                "title": null
            },
            {
                "map": 4,
                "codec": "copy",
                "language": "eng",
                "disposition": "-default-dub-original-comment-lyrics-karaoke-forced+hearing_impaired-visual_impaired-captions",
                "debug": "subtitle.embed-subs",
                "title": "SDH"
            },
            {
                "map": 5,
                "codec": "copy",
                "language": "spa",
                "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
                "debug": "subtitle.embed-subs",
                "title": "Spanish (Latin America)"
            },
            {
                "map": 6,
                "codec": "copy",
                "language": "spa",
                "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions",
                "debug": "subtitle.embed-subs",
                "title": "Spanish (Spain)"
            }
        ],
        "attachment": []
    },
    "preopts": [
        "-fix_sub_duration"
    ],
    "postopts": [
        "-threads",
        "0",
        "-metadata:g",
        "encoding_tool=SMA"
    ],
    "external_subs": [],
    "x": 1356,
    "y": 678,
    "rsi": 50
}
mdhiggins commented 9 months ago

Looking at this it does look likes its working as intended just not quite in line with what you're aiming to do

The script is trying to be as efficient as possible so it looks to eliminate audio streams that are functionality the same content if they share the same number of channels. In your scenario it finds an eac3 and ac3 channel that are paired as equals and both have the same dispositions and number of channels so it takes the higher bitrate one and drops the other

The stream-codec-combination option can help prevent duplicate audio streams but isn't quite intended for this exact scenario

The way I have intended and personally handled this is with a combination of these options

process-same-extensions
bypass-if-copying-all
force-convert

The relevant part of the python code is here

    # Check if video file meets criteria to just bypass conversion
    def canBypassConvert(self, inputfile, info, options=None):
        # Process same extensions
        if self.settings.output_extension == self.parseFile(inputfile)[2]:
            if not self.settings.force_convert and not self.settings.process_same_extensions:
                self.log.info("Input and output extensions are the same so passing back the original file [process-same-extensions: %s]." % self.settings.process_same_extensions)
                return True
            elif info.format.metadata.get('encoder', '').startswith('sma') and not self.settings.force_convert:
                self.log.info("Input and output extensions match and the file appears to have already been processed by SMA, enable force-convert to override [force-convert: %s]." % self.settings.force_convert)
                return True
            elif self.settings.bypass_copy_all and options and len([x for x in [options['video']] + [x for x in options['audio']] + [x for x in options['subtitle']] if x['codec'] != 'copy']) == 0 and len(options['audio']) == len(info.audio) and len(options['subtitle']) == len(info.subtitle) and not self.settings.force_convert:
                self.log.info("Input and output extensions match, the file appears to copying all streams, and is not reducing the number of streams, enable force-convert to override [bypass-if-copying-all] [force-convert: %s]." % self.settings.force_convert)
                return True
        self.log.debug("canBypassConvert returned False.")
        return False

The simplest option is by extensions, which is easy if you're always going from say MKV to MP4, in which case it won't remux or reconvert anything that's an MP4 (but it will retag/update metadata)

This isn't always an option so the script will then check if the file was previously encoded by SMA if process-same-extensions is enabled by looking at the 'encoder' metadata tag which SMA fills in on files that it has previously processed

And finally the bypass-if-copying-all option will analyze the file and run through the whole option generation process and if its determine that's its just remuxing everything anyway it will skip that step and just retag

Tagging is never impacted by these options (though writing individual stream metadata does require remuxing)

Force-convert just disables all these checks and converts everything

If none of these options work for you then custom functions is probably the way to go

SenorSmartyPants commented 9 months ago

Most of my files are MKV, so I am doing MKV->MKV conversions of audio, and dropping subtitles sometimes.

I thought this might be related to running a custom streamTitle and keeping the original audio. But I disabled that and it's still creating a new AC3 on every run. Here's the log from the 2nd run on a file with 1 EAC3 track originally.

./python3 /usr/local/sma/manual.py -a -i /storage/media/Videos/TV/Physical/Season\ 3/Physical\ 3x05\ [WEBDL-720p\ h264][EAC3\ Atmos\ 5.1][ATVP][-NTb]\ -\ Like\ Crazy.mkv Manual processor started. Python 64-bit 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]. Guessit version: 3.7.1. /usr/local/sma/venv/bin/python3 Loading config file /usr/local/sma/config/autoProcess.ini. Processing file /storage/media/Videos/TV/Physical/Season 3/Physical 3x05 [WEBDL-720p h264][EAC3 Atmos 5.1][ATVP][-NTb] - Like Crazy.mkv Input Data { "format": "matroska,webm", "format-fullname": "Matroska / WebM", "video": { "index": 0, "codec": "h264", "bitrate": 2805050, "pix_fmt": "yuv420p", "profile": "high", "fps": 23.976023976023978, "framedata": { "pix_fmt": "yuv420p", "color_space": "bt709", "color_primaries": "bt709", "color_transfer": "bt709" }, "dimensions": "1356x678", "level": 3.2, "field_order": "progressive" }, "audio": [ { "index": 1, "codec": "ac3", "bitrate": 640000, "channels": 6, "samplerate": 48000, "language": "eng", "disposition": "+default-dub+original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions" }, { "index": 2, "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": 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": "eng" }, { "index": 5, "codec": "subrip", "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions", "language": "spa" }, { "index": 6, "codec": "subrip", "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions", "language": "spa" } ], "attachment": [] } Reading video stream. Video codec detected: h264. Pix Fmt: yuv420p. Profile: high. Video codec parameters None. Creating copy video stream from source stream 0. Reading audio streams. The following stream indexes have been identified as being copies: [] [stream-codec-combinations]. Audio detected for stream 1 - ac3 eng 6 channel. Creating copy audio stream from source stream 1. Audio detected for stream 2 - eac3 eng 6 channel. Creating ac3 audio stream from source stream 2. Copying audio stream from source stream 2 format eac3 [audio-copy-original]. Found 0 streams that can be removed from the output file since they will be duplicates [stream-codec-combinations]. Final sorting: ['0->0', '1->1', '2->2'] Final sorting: ['0->0', '1->1', '2->2'] Default audio stream set to eng copy 6 channel stream [audio-default-sorting: ['channels.d', 'map', 'd.comment']]. Reading subtitle streams. Subtitle detected for stream 3 - subrip eng.

Stream 3 is text-based subtitle for codec subrip. Creating copy subtitle stream from source stream 3. Subtitle detected for stream 4 - subrip eng.

Stream 4 is text-based subtitle for codec subrip. Creating copy subtitle stream from source stream 4. Subtitle detected for stream 5 - subrip spa.

Stream 5 is text-based subtitle for codec subrip. Creating copy subtitle stream from source stream 5. Subtitle detected for stream 6 - subrip spa.

Stream 6 is text-based subtitle for codec subrip. Creating copy subtitle stream from source stream 6. Scanned for external subtitles and found 0 results in your approved languages. Final sorting: ['0->0', '1->1', '2->2', '3->3'] Output Data { "source": [ "/storage/media/Videos/TV/Physical/Season 3/Physical 3x05 [WEBDL-720p h264][EAC3 Atmos 5.1][ATVP][-NTb] - Like Crazy.mkv" ], "format": "mkv", "video": { "codec": "copy", "map": 0, "bitrate": 2670.12415, "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": "HD" }, "audio": [ { "map": 1, "codec": "copy", "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": "5.1 Channel (Original)" }, { "map": 2, "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": "5.1 Channel (Original)" }, { "map": 2, "codec": "copy", "bitrate": 768.0, "channels": 6, "language": "eng", "disposition": "-default-dub+original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions", "debug": "audio-copy-original", "title": "5.1 Channel (Original)" } ], "subtitle": [ { "map": 3, "codec": "copy", "language": "eng", "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions", "debug": "subtitle.embed-subs", "title": null }, { "map": 4, "codec": "copy", "language": "eng", "disposition": "-default-dub-original-comment-lyrics-karaoke-forced+hearing_impaired-visual_impaired-captions", "debug": "subtitle.embed-subs", "title": "SDH" }, { "map": 5, "codec": "copy", "language": "spa", "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions", "debug": "subtitle.embed-subs", "title": "Spanish (Latin America)" }, { "map": 6, "codec": "copy", "language": "spa", "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions", "debug": "subtitle.embed-subs", "title": "Spanish (Spain)" } ], "attachment": [] } Preopts [ "-fix_sub_duration" ] Postopts [ "-threads", "0", "-metadata:g", "encoding_tool=SMA" ] Starting conversion.

FFmpeg command:

/usr/local/bin/ffmpeg -fix_sub_duration -i "/storage/media/Videos/TV/Physical/Season 3/Physical 3x05 [WEBDL-720p h264][EAC3 Atmos 5.1][ATVP][-NTb] - Like Crazy.mkv.2.original" -vcodec copy -map 0:0 -metadata:s:v title=HD -metadata:s:v handler_name=HD -c:a:0 copy -map 0:1 -metadata:s:a:0 "title=5.1 Channel (Original)" -metadata:s:a:0 "handler_name=5.1 Channel (Original)" -metadata:s:a:0 language=eng -disposition:a:0 +default-dub+original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions -c:a:1 ac3 -map 0:2 -ac:a:1 6 -b:a:1 768k -metadata:s:a:1 BPS=768000 -metadata:s:a:1 BPS-eng=768000 -metadata:s:a:1 "title=5.1 Channel (Original)" -metadata:s:a:1 "handler_name=5.1 Channel (Original)" -metadata:s:a:1 language=eng -disposition:a:1 -default-dub+original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions -c:a:2 copy -map 0:2 -metadata:s:a:2 "title=5.1 Channel (Original)" -metadata:s:a:2 "handler_name=5.1 Channel (Original)" -metadata:s:a:2 language=eng -disposition:a:2 -default-dub+original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions -c:s:0 copy -map 0:3 -metadata:s:s:0 title= -metadata:s:s:0 handler_name= -metadata:s:s:0 language=eng -disposition:s:0 -default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions -c:s:1 copy -map 0:4 -metadata:s:s:1 title=SDH -metadata:s:s:1 handler_name=SDH -metadata:s:s:1 language=eng -disposition:s:1 -default-dub-original-comment-lyrics-karaoke-forced+hearing_impaired-visual_impaired-captions -c:s:2 copy -map 0:5 -metadata:s:s:2 "title=Spanish (Latin America)" -metadata:s:s:2 "handler_name=Spanish (Latin America)" -metadata:s:s:2 language=spa -disposition:s:2 -default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions -c:s:3 copy -map 0:6 -metadata:s:s:3 "title=Spanish (Spain)" -metadata:s:s:3 "handler_name=Spanish (Spain)" -metadata:s:s:3 language=spa -disposition:s:3 -default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions -f matroska -threads 0 -metadata:g encoding_tool=SMA -y "/storage/media/Videos/TV/Physical/Season 3/Physical 3x05 [WEBDL-720p h264][EAC3 Atmos 5.1][ATVP][-NTb] - Like Crazy.mkv"

[####################] 100% /storage/media/Videos/TV/Physical/Season 3/Physical 3x05 [WEBDL-720p h264][EAC3 Atmos 5.1][ATVP][-NTb] - Like Crazy.mkv created. { "input": "/storage/media/Videos/TV/Physical/Season 3/Physical 3x05 [WEBDL-720p h264][EAC3 Atmos 5.1][ATVP][-NTb] - Like Crazy.mkv.2.original", "input_extension": "original", "input_deleted": false, "output": "/storage/media/Videos/TV/Physical/Season 3/Physical 3x05 [WEBDL-720p h264][EAC3 Atmos 5.1][ATVP][-NTb] - Like Crazy.mkv", "output_extension": "mkv", "options": { "source": [ "/storage/media/Videos/TV/Physical/Season 3/Physical 3x05 [WEBDL-720p h264][EAC3 Atmos 5.1][ATVP][-NTb] - Like Crazy.mkv.2.original" ], "format": "mkv", "video": { "codec": "copy", "map": 0, "bitrate": 2670.12415, "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": "HD" }, "audio": [ { "map": 1, "codec": "copy", "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": "5.1 Channel (Original)" }, { "map": 2, "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": "5.1 Channel (Original)" }, { "map": 2, "codec": "copy", "bitrate": 768.0, "channels": 6, "language": "eng", "disposition": "-default-dub+original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions", "debug": "audio-copy-original", "title": "5.1 Channel (Original)" } ], "subtitle": [ { "map": 3, "codec": "copy", "language": "eng", "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions", "debug": "subtitle.embed-subs", "title": null }, { "map": 4, "codec": "copy", "language": "eng", "disposition": "-default-dub-original-comment-lyrics-karaoke-forced+hearing_impaired-visual_impaired-captions", "debug": "subtitle.embed-subs", "title": "SDH" }, { "map": 5, "codec": "copy", "language": "spa", "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions", "debug": "subtitle.embed-subs", "title": "Spanish (Latin America)" }, { "map": 6, "codec": "copy", "language": "spa", "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions", "debug": "subtitle.embed-subs", "title": "Spanish (Spain)" } ], "attachment": [] }, "preopts": [ "-fix_sub_duration" ], "postopts": [ "-threads", "0", "-metadata:g", "encoding_tool=SMA" ], "external_subs": [], "x": 1356, "y": 678, "rsi": 50 }

Here are my values for those settings.

process-same-extensions = True
bypass-if-copying-all = True
force-convert = False

and my audio section

[Audio]
codec = ac3
languages = 
default-language = 
include-original-language = True
first-stream-of-language = False
channel-bitrate = 128
variable-bitrate = 0
max-bitrate = 0
max-channels = 0
filter = 
profile = 
force-filter = False
sample-rates = 
sample-format = 
copy-original = True
aac-adtstoasc = False
ignored-dispositions = 
force-default = False
unique-dispositions = False
stream-codec-combinations = ac3:eac3
mdhiggins commented 8 months ago

I believe the encoding tool metadata tag doesn't work on MKV files like it does for MP4 (ffmpeg limitation) and thus the check if it was previously encoded by SMA doesn't work on MKVs

You'll probably need a custom script to check for your scenario, though I'm open to suggestions

SenorSmartyPants commented 8 months ago

Which custom function should I look at to do this? Would I keep the settings that I have or change some of them?

Thanks.

SenorSmartyPants commented 6 months ago

Not doing it like this right now. But what I'm doing in #1692 might work.