Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracks "Enabled" flag is set to false in mp4 output container #5823

Open
FireEmerald opened this issue Mar 1, 2024 · 7 comments
Open

Tracks "Enabled" flag is set to false in mp4 output container #5823

FireEmerald opened this issue Mar 1, 2024 · 7 comments

Comments

@FireEmerald
Copy link

FireEmerald commented Mar 1, 2024

Problem Description

HandBrake does set the "Enabled" flag for some Tracks to "false", if the output container is mp4. Most likely HandBrake tries to set this flag (in addition to other flags) to signalize a player which track is a default track or something similar.

The flag can't be set anywhere in the HandBrake GUI and should always be set to true, as it's purpose is not to do anything else than telling a player that a track should be treated as if it were not present. Which is not what anyone wants.

See ISO/IEC 14496-12:2015, section 8.3.2 “Track header box”:

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.

Sample mp4box info of a mp4 file, generated using HandBrake, which contains 2 audio tracks. Note the Track flags: Disabled in the Track 3 Info:

# 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

I contrast, when the output container is mkv, both tracks are enabled.

Activity Log, Crash Log or any other details

<none>

What Operating System are you running?

Windows 10

What version of HandBrake are you running?

1.7.3 (2024021000)

Where did you download HandBrake from?

github

@galad87
Copy link
Contributor

galad87 commented Mar 2, 2024

That's because the tracks are in the same alternate group. Unless you want both to played at the same time, what HandBrake is doing is correct and the it's most compatible way to do it.

@FireEmerald
Copy link
Author

FireEmerald commented Mar 2, 2024

If so, why are they packed into the same group instead of 2 groups? And why are both tracks enabled, when output container is MKV?

I think there is no option in HandBrake to specify anything in regards to alternate groups, or am i wrong?

@galad87
Copy link
Contributor

galad87 commented Mar 2, 2024

They are in an alternate group because only one track should be played back at the same time, if you put them in two different group, then they will play at the same time.

MKV is a totally different container and its fields have a totally different meaning.

@mbunkus
Copy link

mbunkus commented Mar 2, 2024

I am aware of alternate groups & switch groups in MP4. However, I'm not aware of a relationship between the Track_enabled flag & alternate groups in MP4. I'm basing my interpretation of the Track_enabled flag on ISO/IEC 14496-12:2015 section "8.3.2 Track Header Box" which states:

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.

This is pretty clear verbiage. I cannot find anything further in 14496-12:2015 about Track_enabled having any other kind of interaction with alternate groups. Nor does 14496-14:2020 state anything about either topic.

So where can I read up on specs for how Track_enabled is supposed to be handled in alternate groups?

@galad87
Copy link
Contributor

galad87 commented Mar 2, 2024

We added the alternate group flag when it was not officially in ISO File format yet, many years ago. It was based on the QuickTime File format: https://developer.apple.com/documentation/quicktime-file-format/preparing_sound_and_subtitle_alternate_groups_for_use_with_apple_devices

From what I know Apple is the only one that actually reads it, and it used to require the tracks to be disabled even in mp4 years ago. It seems to work even with all the tracks enabled on macOS 14, but I can't check every older iOS and macOS version.

@mbunkus
Copy link

mbunkus commented Mar 2, 2024

MP4 is not QuickTime. MP4 is what's described in ISO 14496-12 & 14496-14. And 14496-12 is quite clear on the semantics of that flag in my opinion.

@galad87
Copy link
Contributor

galad87 commented Mar 2, 2024

I know. But before changing it we will need to check if it breaks some existing players or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants