Set Track Enabled flag always to Yes?

Why is only the first audio/subtitle track “Enabled Flag = Yes” by default and why seems to be no way to say, please enable all tracks by default? We already have a configuration for “Enable items” in regards of copying them by default. The “Enabled Flag” and “Copy Items” result in kind of the same in the output. Both make a track unavailable.

It does not make any sense to me to “Disable” any track, especially because a disabled track is still present in the output file, but it’s not shown in most players.

I would appreciate any feedback on my question, even if it is only the reason behind the decision.

Welcome!

Neither of those points is accurate. By default (= with default settings) all tracks are enabled if the source containers do not provide such a flag, and if they do (such as Matroska) the enabled status the tracks have in the source files will be honored.

You can configure which tracks are enabled by default in the preferences → “Multiplexer” → “Enabling items”.

Thanks for the reply. I deleted my mkvtoolnix-gui.ini file and tried it again. It’s the same. If my input file is a MP4 file which has these two audio tracks:

Summary from MPC-HC
Audio #1
ID                             : 2
Format                         : AAC LC
Format/Info                    : Advanced Audio Codec Low Complexity
Codec ID                       : mp4a-40-2
Duration                       : 49 min 25 s
Bit rate mode                  : Constant
Bit rate                       : 128 kb/s
Channel(s)                     : 2 channels
Channel layout                 : L R
Sampling rate                  : 44.1 kHz
Frame rate                     : 43.066 FPS (1024 SPF)
Compression mode               : Lossy
Stream size                    : 45.2 MiB (3%)
Title                          : Japanese / Japanese
Language                       : Japanese
Default                        : Yes
Alternate group                : 1
Encoded date                   : 2024-02-28 21:51:35 UTC
Tagged date                    : 2024-02-28 21:51:35 UTC
Menus                          : 6

Audio #2
ID                             : 3
Format                         : AAC LC
Format/Info                    : Advanced Audio Codec Low Complexity
Codec ID                       : mp4a-40-2
Duration                       : 49 min 25 s
Bit rate mode                  : Constant
Bit rate                       : 128 kb/s
Channel(s)                     : 2 channels
Channel layout                 : L R
Sampling rate                  : 44.1 kHz
Frame rate                     : 43.066 FPS (1024 SPF)
Compression mode               : Lossy
Stream size                    : 45.2 MiB (3%)
Title                          : German / German
Language                       : German
Default                        : No
Alternate group                : 1
Encoded date                   : 2024-02-28 21:51:35 UTC
Tagged date                    : 2024-02-28 21:51:35 UTC
Menus                          : 6
Summary from ffprobe
{
    "streams": [
        {
            "index": 0,
            "codec_name": "hevc",
            "codec_long_name": "H.265 / HEVC (High Efficiency Video Coding)",
            "profile": "Main",
            "codec_type": "video",
            "codec_tag_string": "hvc1",
            "codec_tag": "0x31637668",
            "width": 1920,
            "height": 1080,
            "coded_width": 1920,
            "coded_height": 1088,
            "closed_captions": 0,
            "film_grain": 0,
            "has_b_frames": 0,
            "sample_aspect_ratio": "1:1",
            "display_aspect_ratio": "16:9",
            "pix_fmt": "yuv420p",
            "level": 120,
            "color_range": "tv",
            "color_space": "bt709",
            "color_transfer": "bt709",
            "color_primaries": "bt709",
            "chroma_location": "left",
            "refs": 1,
            "id": "0x1",
            "r_frame_rate": "24000/1001",
            "avg_frame_rate": "533197500/22238779",
            "time_base": "1/90000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 266865348,
            "duration": "2965.170533",
            "bit_rate": "4073834",
            "nb_frames": "71093",
            "extradata_size": 126,
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "non_diegetic": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            },
            "tags": {
                "creation_time": "2024-02-28T21:51:35.000000Z",
                "language": "und",
                "handler_name": "VideoHandler",
                "vendor_id": "[0][0][0][0]"
            }
        },
        {
            "index": 1,
            "codec_name": "aac",
            "codec_long_name": "AAC (Advanced Audio Coding)",
            "profile": "LC",
            "codec_type": "audio",
            "codec_tag_string": "mp4a",
            "codec_tag": "0x6134706d",
            "sample_fmt": "fltp",
            "sample_rate": "44100",
            "channels": 2,
            "channel_layout": "stereo",
            "bits_per_sample": 0,
            "initial_padding": 0,
            "id": "0x2",
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/44100",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 130766848,
            "duration": "2965.234649",
            "bit_rate": "128000",
            "nb_frames": "127702",
            "extradata_size": 2,
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "non_diegetic": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            },
            "tags": {
                "creation_time": "2024-02-28T21:51:35.000000Z",
                "language": "jpn",
                "handler_name": "Japanese",
                "vendor_id": "[0][0][0][0]"
            }
        },
        {
            "index": 2,
            "codec_name": "aac",
            "codec_long_name": "AAC (Advanced Audio Coding)",
            "profile": "LC",
            "codec_type": "audio",
            "codec_tag_string": "mp4a",
            "codec_tag": "0x6134706d",
            "sample_fmt": "fltp",
            "sample_rate": "44100",
            "channels": 2,
            "channel_layout": "stereo",
            "bits_per_sample": 0,
            "initial_padding": 0,
            "id": "0x3",
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/44100",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 130763776,
            "duration": "2965.164989",
            "bit_rate": "128000",
            "nb_frames": "127699",
            "extradata_size": 2,
            "disposition": {
                "default": 0,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "non_diegetic": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            },
            "tags": {
                "creation_time": "2024-02-28T21:51:35.000000Z",
                "language": "deu",
                "handler_name": "German",
                "vendor_id": "[0][0][0][0]"
            }
        },
        {
            "index": 3,
            "codec_name": "mov_text",
            "codec_long_name": "MOV text",
            "codec_type": "subtitle",
            "codec_tag_string": "tx3g",
            "codec_tag": "0x67337874",
            "width": 1920,
            "height": 162,
            "id": "0x4",
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/90000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 266857290,
            "duration": "2965.081000",
            "bit_rate": "125",
            "nb_frames": "985",
            "extradata_size": 68,
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 1,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "non_diegetic": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            },
            "tags": {
                "creation_time": "2024-02-28T21:51:35.000000Z",
                "language": "deu",
                "handler_name": "German [Full]"
            }
        },
        {
            "index": 4,
            "codec_name": "mov_text",
            "codec_long_name": "MOV text",
            "codec_type": "subtitle",
            "codec_tag_string": "tx3g",
            "codec_tag": "0x67337874",
            "width": 1920,
            "height": 162,
            "id": "0x5",
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/90000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 266857290,
            "duration": "2965.081000",
            "bit_rate": "6",
            "nb_frames": "84",
            "extradata_size": 68,
            "disposition": {
                "default": 0,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "non_diegetic": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            },
            "tags": {
                "creation_time": "2024-02-28T21:51:35.000000Z",
                "language": "deu",
                "handler_name": "German [Forced]"
            }
        },
        {
            "index": 5,
            "codec_name": "bin_data",
            "codec_long_name": "binary data",
            "codec_type": "data",
            "codec_tag_string": "text",
            "codec_tag": "0x74786574",
            "id": "0x6",
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/1000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 2965171,
            "duration": "2965.171000",
            "nb_frames": "3",
            "extradata_size": 43,
            "disposition": {
                "default": 0,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "non_diegetic": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            },
            "tags": {
                "creation_time": "2024-02-28T21:51:35.000000Z",
                "language": "eng",
                "handler_name": "SubtitleHandler"
            }
        }
    ],
    "format": {
        "filename": "replaced.mp4",
        "nb_streams": 6,
        "nb_programs": 0,
        "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
        "format_long_name": "QuickTime / MOV",
        "start_time": "0.000000",
        "duration": "2965.234649",
        "size": "1607805666",
        "bit_rate": "4337749",
        "probe_score": 100,
        "tags": {
            "major_brand": "mp42",
            "minor_version": "512",
            "compatible_brands": "mp42iso2mp41",
            "creation_time": "2024-02-28T21:51:35.000000Z",
            "encoder": "HandBrake 1.7.3 2024021000"
        }
    }
}

Both audio tracks get the Default track flag set to Yes and the first track has Track enabled = Yes and the second has No.

Am I wrong or are these flags not really what’s set inside the input file and not what you said is the “default settings”.

MP4 is another container that provides an “enabled” track property. As stated earlier, the existing values are honored.

Where is the “enabled” track property inside the ffprobe output from above? I don’t see anything which sounds like that - sorry, perhaps i’m blind or ffprobe does not output it. Ah my command was: .\ffprobe.exe -v quiet -print_format json -show_format -show_streams -print_format json file.mp4

ffmpeg does indeed not output this element. Technically speaking, we’re talking about the tkhd header atom’s flags field which has the bit track_enabled set. See ISO/IEC 14496-12:2015, section 8.3.2 “Track header box”. It has the following to say about this flag:

flags is a 24‐bit integer with flags; the following values are defined:

  • Track_enabled: Indicates that the track is enabled. Flag value is 0x000001. A disabled track (the low bit is zero) is treated as if it were not present.

When i play my input MP4 file all audio tracks are shown. When i process it via MKVToolNix GUI, where 1 audio track has the “Track Enabled” flag set to “False” and play the output MP4 file, this audio track is gone (hidden, but still existent).

Thus i would assume my player is interpreting the flags correctly and MKVToolNix does not detect it correctly while reading the input file. I would be happy to validate that, but as i don’t know any other software which shows this “exotic” flag, there is nothing i can do.

Anyways, the main point is that this flag makes 0 sense in the real world. If you don’t want a track, don’t copy it. It has exactly the same outcome at the end. Yes the flag is in the specification and it’s totally fine that you support it in MKVToolNix, but don’t you think in a user perspective that it would be a good idea to allow to set it to True by default? Especially when there is no support in most(?) other software for it.

Or they’re completely ignoring them.

I’m not interested in spending time on changing the current behavior. I’m not opposed to having an option (both in mkvmerge and in the GUI) for ignoring the flag & always enabling tracks. I just won’t be the one implementing such a feature. Patches are more than welcome; this is Open Source, after all.

Then please explain why in the output file (processed by MKVToolNix) the audio stream with “Track enabled = false” is gone/hidden, when played in the same player. If they would completely ignore it, the track would still be displayed.

It’s completely possible and very common that players support a feature for one container but not for another. If you want a more specific answer, you’ll have to ask the developers of those players. I’m not one of them.

Ah okay, you are right. The output file is of course a MKV file instead of MP4 so they could ignore it for MP4 and respect it in MKV… if you know any software which shows the mentioned flag for mp4 containers, i would really appreciate it. Thanks for your answers. Thats the source code of the player which i use - by the way: Releases · clsid2/mpc-hc · GitHub and the input MP4 file was created using HandBrake.

mkvmerge can, of course, but I guess you’re asking about tools other than MKVToolNix. The MP4Box tool from the gpac project can output that flag, too. Here’s an example how the same file is reported by mkvmerge & MP4Box (the output of mkvmerge was manually shortened to the pertinent pieces of information):

[0 mosu@sweet-chili (main) ~/prog/video/mkvtoolnix/tests] mkvmerge -J data/mp4/1080p-DTS-HD-7.1.mp4
{
  "tracks": [
    {
      "codec": "AVC/H.264/MPEG-4p10",
      "id": 0,
      "properties": {
        "enabled_track": true,
      },
      "type": "video"
    },
    {
      "codec": "AAC",
      "id": 1,
      "properties": {
        "enabled_track": true,
      },
      "type": "audio"
    },
    {
      "codec": "AC-3",
      "id": 2,
      "properties": {
        "enabled_track": false,
      },
      "type": "audio"
    },
    {
      "codec": "DTS-HD Master Audio",
      "id": 3,
      "properties": {
        "enabled_track": false,
      },
      "type": "audio"
    }
  ],
}
[0 mosu@sweet-chili (main) ~/prog/video/mkvtoolnix/tests] MP4Box -infox data/mp4/1080p-DTS-HD-7.1.mp4 2>&1 | grep -Ei '^#|^track flags'
# Track 1 Info - ID 1 - TimeScale 90000
Track flags: Enabled
# Track 2 Info - ID 2 - TimeScale 48000
Track flags: Enabled In Movie
# Track 3 Info - ID 3 - TimeScale 48000
Track flags: Disabled In Movie
# Track 4 Info - ID 4 - TimeScale 48000
Track flags: Disabled In Movie
# Track 5 Info - ID 6 - TimeScale 1000
Track flags: Disabled In Movie In Preview Size is AspectRatio

I don’t think MediaInfo can output the information; that would normally be my go-to option for such information, especially for cross-format support. MP4Box can only be used with MP4 files.

The flag is indeed present in my input MP4 file:

Partial output of .\mp4box.exe -info file.mp4
# Track 2 Info - ID 2 - TimeScale 44100
Media Duration 00:49:25.234
Track has 1 edits: track duration is 00:49:25.235
Track flags: Enabled In Movie
Media Language: Japanese (jpn)
Media Samples: 127702
2 UDTA types:
        name: Japanese
        titl:  unknown type (15 bytes)
Alternate Group ID 1
Media Type: soun:mp4a
        MPEG-4 Audio AAC LC (AOT=2 implicit) - 2 Channel(s) - SampleRate 44100
        RFC6381 Codec Parameters: mp4a.40.2
        All samples are sync
        Max sample duration: 1024 / 44100

# Track 3 Info - ID 3 - TimeScale 44100
Media Duration 00:49:25.164
Track has 1 edits: track duration is 00:49:25.165
Track flags: Disabled In Movie
Media Language: German (deu)
Media Samples: 127699
2 UDTA types:
        name: German
        titl:  unknown type (13 bytes)
Alternate Group ID 1
Media Type: soun:mp4a
        MPEG-4 Audio AAC LC (AOT=2 implicit) - 2 Channel(s) - SampleRate 44100
        RFC6381 Codec Parameters: mp4a.40.2
        All samples are sync
        Max sample duration: 1024 / 44100
Partial output of .\mkvmerge.exe -J file.mp4
{
      "codec": "AAC",
      "id": 1,
      "properties": {
        "audio_bits_per_sample": 16,
        "audio_channels": 2,
        "audio_sampling_frequency": 44100,
        "enabled_track": true,
        "language": "jpn",
        "number": 2
      },
      "type": "audio"
    },
    {
      "codec": "AAC",
      "id": 2,
      "properties": {
        "audio_bits_per_sample": 16,
        "audio_channels": 2,
        "audio_sampling_frequency": 44100,
        "enabled_track": false,
        "language": "ger",
        "number": 3
      },
      "type": "audio"
    },

Downloaded mp4box from here, read the docu and created the following command.

.\mp4box.exe -enable 3 "in.mp4" -out "out.mp4"

This enables the mp4box track with “ID 3”. I then re-checked it via -info and imported it to MKVToolNix GUI. Both audio tracks are indeed now Enabled by default.

So the problem is HandBrake, which was used to create the input file. I didn’t specify anything there and there is no way to specify dis-/enabled tracks. A track is a track, that’s it. Perhaps i open an issue there, but most likely they use ffmpeg under the hood or similar software which maybe does not support the flag at all.

My very wild & uninformed guess is that Handbrake (which I generally love as a program, BTW) tries to use the “enabled” flag as some kind of method to set one track of each type as the default track to play. But that’s not what that MP4 flag is supposed to do. Anyway, as I said: wild guess.

BTW: Handbrake can create Matroska files directly. You don’t need to go through MP4.

I know HandBrake is able to output MKV directly, but they do not support Blu ray subtitles (.sub), even for MKV. So I used HandBrake to convert videos and then searched for a way to add ontop of the existing mp4s those subtitles.

Maybe the better way would have been to create MKV files using HandBrake and hope that the “enabled” flag is not set there, because Blu ray subs are best supported in MKV instead of MP4.

Update:
The HandBrake input files do have all tracks enabled, thus the option in HandBrake to passthru metadata is not the issue. Generating the same video again using MKV as output container showed that the Enabled flag is now always set to true. So it’s only a problem when HandBrakes output container is set to MP4.

Input file directly encoded to MKV instead of MP4
{
      "codec": "AAC",
      "id": 1,
      "properties": {
        "audio_channels": 2,
        "audio_sampling_frequency": 44100,
        "codec_id": "A_AAC",
        "codec_private_data": "1210",
        "codec_private_length": 2,
        "default_track": true,
        "enabled_track": true,
        "forced_track": false,
        "language": "jpn",
        "minimum_timestamp": 0,
        "num_index_entries": 0,
        "number": 2,
        "tag_duration": "00:49:25.234000000",
        "track_name": "Japanese",
        "uid": 13369331271998949791
      },
      "type": "audio"
    },
    {
      "codec": "AAC",
      "id": 2,
      "properties": {
        "audio_channels": 2,
        "audio_sampling_frequency": 44100,
        "codec_id": "A_AAC",
        "codec_private_data": "1210",
        "codec_private_length": 2,
        "default_track": false,
        "enabled_track": true,
        "forced_track": false,
        "language": "ger",
        "minimum_timestamp": 0,
        "num_index_entries": 0,
        "number": 3,
        "tag_duration": "00:49:25.165000000",
        "track_name": "German",
        "uid": 15390410983791501987
      },
      "type": "audio"
    },

Let’s see what happens in this issue on github.

@mbunkus If you could take a short look at the conversation at Tracks "Enabled" flag is set to false in mp4 output container · Issue #5823 · HandBrake/HandBrake · GitHub - the guys from HandBrake say that the Enabled flag has a entirely different meaning in mp4 vs. mkv. If that’s correct what they say, MKVToolNix GUI does map the flag 1:1 from mp4 input to mkv output, but thats incorrect in terms of meaning and interpretation what the flag is doing. The mapping would be wrong. You could also comment directly in the github issue for sure.