diff mbox series

[FFmpeg-devel] avfilter/vf_subtitles: allow using embedded fonts

Message ID 20210502210201.25045-1-oneric@oneric.de
State New
Headers show
Series [FFmpeg-devel] avfilter/vf_subtitles: allow using embedded fonts
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Oneric May 2, 2021, 9:02 p.m. UTC
ASS subtitles can have encoded fonts embedded into the subtitle file
itself. Allow libass to load those, to render subs as intended.
---


A sample file for ASS with embedded font can be at the following link.
If everything works, the 'A' will render as a quad; see image:
https://raw.githubusercontent.com/TheOneric/libass-regression-tests-tmp/master/regression/embedded-font/efont.ass
https://raw.githubusercontent.com/TheOneric/libass-regression-tests-tmp/master/regression/embedded-font/efont-1000.png

Prior to libass commit 1140b6b885c89d37eef13dc1f31f144e9a76a4d7, included
in libass release 0.15.1, a libass-bug would have prevented this from actually working.
To test this a recent libass is therefore required.
'ass_extract_fonts' itself however has been part of libass' API ever since its
first standalone release, so calling this does not break compatibility with
older versions and at worst just nothing happens.
Use eg the follwoing to check:
  ./ffmpeg -f lavfi -i "color=cyan:640x480:d=5" -vf "ass=efont.ass" -f matroska - | ./ffplay -autoexit -

---
 libavfilter/vf_subtitles.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Oneric May 13, 2021, 3:45 p.m. UTC | #1
On Sun, May 02, 2021 at 23:02:02 +0200, Oneric wrote:
> ASS subtitles can have encoded fonts embedded into the subtitle file
> itself. Allow libass to load those, to render subs as intended.
> ---
>  libavfilter/vf_subtitles.c | 1 +
>  1 file changed, 1 insertion(+)

pinging for review
diff mbox series

Patch

diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c
index 493eb5f424..ab32e1b7f3 100644
--- a/libavfilter/vf_subtitles.c
+++ b/libavfilter/vf_subtitles.c
@@ -111,6 +111,7 @@  static av_cold int init(AVFilterContext *ctx)
     ass_set_message_cb(ass->library, ass_log, ctx);
 
     ass_set_fonts_dir(ass->library, ass->fontsdir);
+    ass_set_extract_fonts(ass->library, 1);
 
     ass->renderer = ass_renderer_init(ass->library);
     if (!ass->renderer) {