summaryrefslogtreecommitdiffstats
path: root/libhb/muxmp4.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2010-05-24 21:53:48 +0000
committerjstebbins <[email protected]>2010-05-24 21:53:48 +0000
commitddb445bf2829b7e6311a24453adc4a39b0215fb5 (patch)
treefb6b6b292b4707adfd6b5025fa9c0172e73097b8 /libhb/muxmp4.c
parent139cac98014fc013254bf6183513a50cd99fb874 (diff)
add support for Nero vobsubs in mp4
Note that these do not work with any apple products that I know of. Perian might be able to do something with them. MPlayer and VLC both grok nero vobsubs. libhb, cli, and lingui updated. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3325 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/muxmp4.c')
-rw-r--r--libhb/muxmp4.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/libhb/muxmp4.c b/libhb/muxmp4.c
index 01ba94004..3c878fdfc 100644
--- a/libhb/muxmp4.c
+++ b/libhb/muxmp4.c
@@ -520,6 +520,46 @@ static int MP4Init( hb_mux_object_t * m )
MP4SetTrackIntegerProperty(m->file, mux_data->track, "tkhd.flags", (TRACK_DISABLED | TRACK_IN_MOVIE));
}
}
+ else if( subtitle && subtitle->format == PICTURESUB &&
+ subtitle->config.dest == PASSTHRUSUB )
+ {
+ mux_data = calloc(1, sizeof( hb_mux_data_t ) );
+ subtitle->mux_data = mux_data;
+ mux_data->subtitle = 1;
+ mux_data->sub_format = subtitle->format;
+
+ mux_data->track = MP4AddSubpicTrack( m->file, 90000, title->width, title->height );
+
+ MP4SetTrackLanguage(m->file, mux_data->track, subtitle->iso639_2);
+
+ /* Tune track chunk duration */
+ MP4TuneTrackDurationPerChunk( m, mux_data->track );
+ uint8_t palette[16][4];
+ int ii;
+ for ( ii = 0; ii < 16; ii++ )
+ {
+ palette[ii][0] = 0;
+ palette[ii][1] = (subtitle->palette[ii] >> 16) & 0xff;
+ palette[ii][2] = (subtitle->palette[ii] >> 8) & 0xff;
+ palette[ii][3] = (subtitle->palette[ii]) & 0xff;
+ }
+ if (!(MP4SetTrackESConfiguration( m->file, mux_data->track,
+ (uint8_t*)palette, 16 * 4 )))
+ {
+ hb_error("muxmp4.c: MP4SetTrackESConfiguration failed!");
+ *job->die = 1;
+ return 0;
+ }
+ if ( !subtitle_default || subtitle->config.default_track ) {
+ /* Enable the default subtitle track */
+ MP4SetTrackIntegerProperty(m->file, mux_data->track, "tkhd.flags", (TRACK_ENABLED | TRACK_IN_MOVIE));
+ subtitle_default = 1;
+ }
+ else
+ {
+ MP4SetTrackIntegerProperty(m->file, mux_data->track, "tkhd.flags", (TRACK_DISABLED | TRACK_IN_MOVIE));
+ }
+ }
}
if (job->chapter_markers)
@@ -1048,6 +1088,39 @@ static int MP4Mux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
mux_data->sum_dur += (buf->stop - buf->start);
}
+ else if( mux_data->sub_format == PICTURESUB )
+ {
+ /* Write an empty sample */
+ if ( mux_data->sum_dur < buf->start )
+ {
+ uint8_t empty[2] = {0,0};
+ if( !MP4WriteSample( m->file,
+ mux_data->track,
+ empty,
+ 2,
+ buf->start - mux_data->sum_dur,
+ 0,
+ 1 ))
+ {
+ hb_error("Failed to write to output file, disk full?");
+ *job->die = 1;
+ }
+ mux_data->sum_dur += buf->start - mux_data->sum_dur;
+ }
+ if( !MP4WriteSample( m->file,
+ mux_data->track,
+ buf->data,
+ buf->size,
+ buf->stop - buf->start,
+ 0,
+ 1 ))
+ {
+ hb_error("Failed to write to output file, disk full?");
+ *job->die = 1;
+ }
+
+ mux_data->sum_dur += (buf->stop - buf->start);
+ }
}
else
{