diff options
author | jstebbins <[email protected]> | 2010-09-28 22:10:49 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2010-09-28 22:10:49 +0000 |
commit | 03b2ce0e91c4e4ed44445a075ef5f35bc052b5b8 (patch) | |
tree | 24a1def4ca91cba98676508c6a3b1482ba131cb5 /libhb/stream.c | |
parent | f1997be4ed1dd373316ac842685f18a6f8ab05ba (diff) |
SSA subtitle burn in
Anime fans rejoice! This patch adds SSA subtitle burn-in support with libass.
Therefore SSA subtitles should now be rendered in full quality, with the
appropriate embedded fonts and positioning information.
Thanks to davidfstr
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3557 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/stream.c')
-rw-r--r-- | libhb/stream.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/libhb/stream.c b/libhb/stream.c index 58b2506f0..85a891c7b 100644 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -3181,9 +3181,55 @@ static void add_ffmpeg_subtitle( hb_title_t *title, hb_stream_t *stream, int id strcpy( subtitle->lang, language->eng_name ); strncpy( subtitle->iso639_2, language->iso639_2, 4 ); + // Copy the extradata for the subtitle track + subtitle->extradata = malloc( codec->extradata_size ); + memcpy( subtitle->extradata, codec->extradata, codec->extradata_size ); + subtitle->extradata_size = codec->extradata_size; + hb_list_add(title->list_subtitle, subtitle); } +static char *get_ffmpeg_metadata_value( AVMetadata *m, char *key ) +{ + AVMetadataTag *tag = NULL; + while ( tag = av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX) ) + { + if ( !strcmp( key, tag->key ) ) + { + return tag->value; + } + } + return NULL; +} + +static void add_ffmpeg_attachment( hb_title_t *title, hb_stream_t *stream, int id ) +{ + AVStream *st = stream->ffmpeg_ic->streams[id]; + AVCodecContext *codec = st->codec; + + enum attachtype type; + switch ( codec->codec_id ) + { + case CODEC_ID_TTF: + type = FONT_TTF_ATTACH; + break; + default: + // Ignore unrecognized attachment type + return; + } + + hb_attachment_t *attachment = calloc( 1, sizeof(*attachment) ); + + // Copy the attachment name and data + attachment->type = type; + attachment->name = strdup( get_ffmpeg_metadata_value( st->metadata, "filename" ) ); + attachment->data = malloc( codec->extradata_size ); + memcpy( attachment->data, codec->extradata, codec->extradata_size ); + attachment->size = codec->extradata_size; + + hb_list_add(title->list_attachment, attachment); +} + static hb_title_t *ffmpeg_title_scan( hb_stream_t *stream ) { AVFormatContext *ic = stream->ffmpeg_ic; @@ -3244,6 +3290,10 @@ static hb_title_t *ffmpeg_title_scan( hb_stream_t *stream ) { add_ffmpeg_subtitle( title, stream, i ); } + else if ( ic->streams[i]->codec->codec_type == CODEC_TYPE_ATTACHMENT ) + { + add_ffmpeg_attachment( title, stream, i ); + } } title->container_name = strdup( ic->iformat->name ); |