From 32f5fd87588bacc372b620b6543d9906a1598a99 Mon Sep 17 00:00:00 2001 From: jbrjake Date: Tue, 12 Jun 2007 03:39:39 +0000 Subject: [PATCH] Disables extra audio tracks so they don't all play over the main audio track in QuickTime. They can be re-enabled from the Properties menu in QT Pro or with Dumpster. Shouldn't have any affect on people who use sane video players. Props to eddyg for reporting the issue, identifying the atom in question, and castigating me for my lazy and unkempt coding ways. git-svn-id: svn://localhost/HandBrake/trunk@606 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/muxmp4.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/libhb/muxmp4.c b/libhb/muxmp4.c index 284c4ce6..cfaf11eb 100644 --- a/libhb/muxmp4.c +++ b/libhb/muxmp4.c @@ -137,6 +137,10 @@ static int MP4Init( hb_mux_object_t * m ) hb_mux_data_t * mux_data; int i; u_int16_t language_code; + + /* Flags for enabling/disabling tracks in an MP4. */ + typedef enum { TRACK_DISABLED = 0x0, TRACK_ENABLED = 0x1, TRACK_IN_MOVIE = 0x2, TRACK_IN_PREVIEW = 0x4, TRACK_IN_POSTER = 0x8} track_header_flags; + /* Create an empty mp4 file */ m->file = MP4Create( job->file, MP4_DETAILS_ERROR, 0 ); @@ -295,12 +299,23 @@ static int MP4Init( hb_mux_object_t * m ) /* Set the correct number of channels for this track */ reserved2[9] = (u_int8_t)HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(audio->amixdown); MP4SetTrackBytesProperty(m->file, mux_data->track, "mdia.minf.stbl.stsd.mp4a.reserved2", reserved2, sizeof(reserved2)); - - /* store a reference to the first audio track, - so we can use it to feed the chapter text track's sample rate */ - if (i == 0) { - firstAudioTrack = mux_data->track; - } + + /* store a reference to the first audio track, + so we can use it to feed the chapter text track's sample rate */ + if (i == 0) { + firstAudioTrack = mux_data->track; + + /* Enable the first audio track */ + MP4SetTrackIntegerProperty(m->file, mux_data->track, "tkhd.flags", (TRACK_ENABLED | TRACK_IN_MOVIE)); + } + + else + /* Disable the other audio tracks so QuickTime doesn't play + them all at once. */ + { + MP4SetTrackIntegerProperty(m->file, mux_data->track, "tkhd.flags", (TRACK_DISABLED | TRACK_IN_MOVIE)); + hb_log("Disabled extra audio track %i", mux_data->track-1); + } } -- 2.11.0