summaryrefslogtreecommitdiffstats
path: root/libhb/muxmp4.c
diff options
context:
space:
mode:
authorvan <[email protected]>2008-07-26 01:04:00 +0000
committervan <[email protected]>2008-07-26 01:04:00 +0000
commite529b1dbda55f01e21fe6fb04ee7f85c2e755725 (patch)
tree1748a00de07c035323dc9c3c9597ec9fefdeae7e /libhb/muxmp4.c
parente3298b9003a7ee6070842516818bc08d8b0a65ed (diff)
- in encx264, if an video frame is larger than init_delay split it into pieces so we don't get jerky output caused by out-of-order frames.
- add an explicit EOF for all streams, not just video. - don't generate extra audio silence at the end of an encode (don't need it with explicit eof). - get rid of 80ms initial delay in AAC encode & flush final four frames buffered in encoder. - put mp4 'chap' atom on first track (usually video) rather than first audio track since we can now do video without audio (atom just needs to go on an enabled media track & video is always enabled). git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1581 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/muxmp4.c')
-rw-r--r--libhb/muxmp4.c52
1 files changed, 19 insertions, 33 deletions
diff --git a/libhb/muxmp4.c b/libhb/muxmp4.c
index db0c9b716..b61d579c8 100644
--- a/libhb/muxmp4.c
+++ b/libhb/muxmp4.c
@@ -285,9 +285,6 @@ static int MP4Init( hb_mux_object_t * m )
MP4SetTrackFloatProperty(m->file, mux_data->track, "tkhd.width", job->width * (width / height));
}
- /* firstAudioTrack will be used to reference the first audio track when we add a chapter track */
- MP4TrackId firstAudioTrack = 0;
-
/* add the audio tracks */
for( i = 0; i < hb_list_count( title->list_audio ); i++ )
{
@@ -344,15 +341,10 @@ static int MP4Init( hb_mux_object_t * m )
/* If we ever upgrade mpeg4ip, the line above should be replaced with the line below.*/
// MP4SetTrackIntegerProperty(m->file, mux_data->track, "mdia.minf.stbl.stsd.mp4a.channels", (u_int16_t)HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(audio->amixdown));
- /* 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. */
@@ -365,14 +357,17 @@ static int MP4Init( hb_mux_object_t * m )
if (job->chapter_markers)
{
- /* add a text track for the chapters */
- MP4TrackId textTrack;
- textTrack = MP4AddChapterTextTrack(m->file, firstAudioTrack);
+ /* add a text track for the chapters. We add the 'chap' atom to track
+ one which is usually the video track & should never be disabled.
+ The Quicktime spec says it doesn't matter which media track the
+ chap atom is on but it has to be an enabled track. */
+ MP4TrackId textTrack;
+ textTrack = MP4AddChapterTextTrack(m->file, 1);
m->chapter_track = textTrack;
m->chapter_duration = 0;
m->current_chapter = job->chapter_start;
- }
+ }
/* Add encoded-by metadata listing version and build date */
char *tool_string;
@@ -501,30 +496,21 @@ static int MP4End( hb_mux_object_t * m )
if( m->job->chapter_markers )
{
int64_t duration = m->sum_dur - m->chapter_duration;
- if ( duration <= 0 )
+ /* The final chapter can have a very short duration - if it's less
+ * than a second just skip it. */
+ if ( duration >= m->samplerate )
{
- /* The initial & final chapters can have very short durations
- * (less than the error in our total duration estimate) so
- * the duration calc above can result in a negative number.
- * when this happens give the chapter a short duration (1/3
- * of an ntsc frame time). */
- duration = 1000 * m->samplerate / 90000;
- }
-
- struct hb_text_sample_s *sample = MP4GenerateChapterSample( m, duration,
- m->current_chapter + 1 );
- if( !MP4WriteSample(m->file,
- m->chapter_track,
- sample->sample,
- sample->length,
- sample->duration,
- 0, true) )
- {
- hb_error("Failed to write to output file, disk full?");
- *job->die = 1;
+ struct hb_text_sample_s *sample = MP4GenerateChapterSample( m, duration,
+ m->current_chapter + 1 );
+ if( ! MP4WriteSample(m->file, m->chapter_track, sample->sample,
+ sample->length, sample->duration, 0, true) )
+ {
+ hb_error("Failed to write to output file, disk full?");
+ *job->die = 1;
+ }
+ free(sample);
}
- free(sample);
}
if (job->areBframes)