[PATCH 0/2] Improve .otf attachment support
I did only test with MKV container. Please comment; this fixes ticket 2207 for me. Alexander Strasser (2): Pass application/vnd.ms-opentype attachments to libass demux_lavf: Also add AV_CODEC_ID_OTF attachments libmpdemux/demux_lavf.c | 5 +++-- mplayer.c | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) --
Make those font attachments work with at least demux_mkv. Fix part of ticket 2207 Signed-off-by: Alexander Strasser <eclipse7@gmx.net> --- mplayer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mplayer.c b/mplayer.c index 6a32e88..482bf53 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3436,6 +3436,7 @@ goto_enable_cache: if (extract_embedded_fonts && att->name && att->type && att->data && att->data_size && (strcmp(att->type, "application/x-truetype-font") == 0 || + strcmp(att->type, "application/vnd.ms-opentype") == 0 || strcmp(att->type, "application/x-font") == 0)) ass_add_font(ass_library, att->name, att->data, att->data_size); } --
Le quartidi 4 brumaire, an CCXXIII, Alexander Strasser a écrit :
Make those font attachments work with at least demux_mkv.
Fix part of ticket 2207 Signed-off-by: Alexander Strasser <eclipse7@gmx.net> --- mplayer.c | 1 + 1 file changed, 1 insertion(+)
I think this is a good idea.
diff --git a/mplayer.c b/mplayer.c index 6a32e88..482bf53 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3436,6 +3436,7 @@ goto_enable_cache: if (extract_embedded_fonts && att->name && att->type && att->data && att->data_size && (strcmp(att->type, "application/x-truetype-font") == 0 ||
+ strcmp(att->type, "application/vnd.ms-opentype") == 0 ||
This one seems widely used, especially by mkvmerge, so it must be there. But while you are at it, maybe add the official MIME type for OpenType and other fonts, i.e. application/font-sfnt.
strcmp(att->type, "application/x-font") == 0)) ass_add_font(ass_library, att->name, att->data, att->data_size); } --
Regards, -- Nicolas George
On 2014-10-25 13:42 +0200, Nicolas George wrote:
Le quartidi 4 brumaire, an CCXXIII, Alexander Strasser a écrit :
Make those font attachments work with at least demux_mkv.
Fix part of ticket 2207 Signed-off-by: Alexander Strasser <eclipse7@gmx.net> --- mplayer.c | 1 + 1 file changed, 1 insertion(+)
I think this is a good idea.
Committed as is because it should fix a reported issue and I didn't want to delay it.
diff --git a/mplayer.c b/mplayer.c index 6a32e88..482bf53 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3436,6 +3436,7 @@ goto_enable_cache: if (extract_embedded_fonts && att->name && att->type && att->data && att->data_size && (strcmp(att->type, "application/x-truetype-font") == 0 ||
+ strcmp(att->type, "application/vnd.ms-opentype") == 0 ||
This one seems widely used, especially by mkvmerge, so it must be there.
But while you are at it, maybe add the official MIME type for OpenType and other fonts, i.e. application/font-sfnt.
I will send a new patch for that.
strcmp(att->type, "application/x-font") == 0)) ass_add_font(ass_library, att->name, att->data, att->data_size); } --
Thank you for reviewing, Alexander
Make those font attachments work with demux_lavf. Fix other part of 2207 Signed-off-by: Alexander Strasser <eclipse7@gmx.net> --- libmpdemux/demux_lavf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c index de523df..ddc05d6 100644 --- a/libmpdemux/demux_lavf.c +++ b/libmpdemux/demux_lavf.c @@ -483,10 +483,11 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) { break; } case AVMEDIA_TYPE_ATTACHMENT:{ - if (st->codec->codec_id == AV_CODEC_ID_TTF) { + if (st->codec->codec_id == AV_CODEC_ID_TTF || st->codec->codec_id == AV_CODEC_ID_OTF) { AVDictionaryEntry *fnametag = av_dict_get(st->metadata, "filename", NULL, 0); + AVDictionaryEntry *mimetype = av_dict_get(st->metadata, "mimetype", NULL, 0); demuxer_add_attachment(demuxer, fnametag ? fnametag->value : NULL, - "application/x-truetype-font", + mimetype ? mimetype->value : "application/x-truetype-font", codec->extradata, codec->extradata_size); } break; --
Le quartidi 4 brumaire, an CCXXIII, Alexander Strasser a écrit :
Make those font attachments work with demux_lavf.
Fix other part of 2207
Signed-off-by: Alexander Strasser <eclipse7@gmx.net> --- libmpdemux/demux_lavf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
This looks right too, except for a small nitpick:
diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c index de523df..ddc05d6 100644 --- a/libmpdemux/demux_lavf.c +++ b/libmpdemux/demux_lavf.c @@ -483,10 +483,11 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) { break; } case AVMEDIA_TYPE_ATTACHMENT:{ - if (st->codec->codec_id == AV_CODEC_ID_TTF) { + if (st->codec->codec_id == AV_CODEC_ID_TTF || st->codec->codec_id == AV_CODEC_ID_OTF) { AVDictionaryEntry *fnametag = av_dict_get(st->metadata, "filename", NULL, 0); + AVDictionaryEntry *mimetype = av_dict_get(st->metadata, "mimetype", NULL, 0); demuxer_add_attachment(demuxer, fnametag ? fnametag->value : NULL, - "application/x-truetype-font",
+ mimetype ? mimetype->value : "application/x-truetype-font",
application/x-font would seem like a saner fallback if it works.
codec->extradata, codec->extradata_size); } break; --
Regards, -- Nicolas George
On 2014-10-25 13:43 +0200, Nicolas George wrote:
Le quartidi 4 brumaire, an CCXXIII, Alexander Strasser a écrit :
Make those font attachments work with demux_lavf.
Fix other part of 2207
Signed-off-by: Alexander Strasser <eclipse7@gmx.net> --- libmpdemux/demux_lavf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
This looks right too, except for a small nitpick:
[...]
AVDictionaryEntry *fnametag = av_dict_get(st->metadata, "filename", NULL, 0); + AVDictionaryEntry *mimetype = av_dict_get(st->metadata, "mimetype", NULL, 0); demuxer_add_attachment(demuxer, fnametag ? fnametag->value : NULL, - "application/x-truetype-font",
+ mimetype ? mimetype->value : "application/x-truetype-font",
application/x-font would seem like a saner fallback if it works.
I thought about that too... I am not sure it is actually saner, but it works for me. And it should usually not matter anyway AFAICT. Committed with the requested change. Thanks, Alexander
participants (2)
-
Alexander Strasser -
Nicolas George