[FFmpeg-devel] [PATCH] vf_subtitles: add line_spacing option

Clément Bœsch ubitux at gmail.com
Tue May 21 22:23:01 CEST 2013


On Thu, May 16, 2013 at 11:33:35PM +0200, Jean First wrote:
> On Thu May 16 2013 14:38:04 GMT+0200 (CEST), Clément Bœsch wrote:
> >On Thu, May 16, 2013 at 11:10:08AM +0200, Jean First wrote:
> >>Signed-off-by: Jean First <jeanfirst at gmail.com>
> >>---
> >>
> >>  Unfortunately the line spacing can not be specified in the ssa/ass file
> >>
> >>  doc/filters.texi           | 3 +++
> >>  libavfilter/vf_subtitles.c | 4 ++++
> >>  2 files changed, 7 insertions(+)
> >>
> >>diff --git a/doc/filters.texi b/doc/filters.texi
> >>index cf2c1a4..3972833 100644
> >>--- a/doc/filters.texi
> >>+++ b/doc/filters.texi
> >>@@ -6158,6 +6158,9 @@ Specify the size of the original video, the video for which the ASS file
> >>  was composed. Due to a misdesign in ASS aspect ratio arithmetic, this is
> >>  necessary to correctly scale the fonts if the aspect ratio has been changed.
> >>+ at item line_spacing
> >>+Specify the height of the line spacing.
> >>+
> >>  @item charenc
> >>  Set subtitles input character encoding. @code{subtitles} filter only. Only
> >>  useful if not UTF-8.
> >>diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c
> >>index b5f5bc9..ea45e71 100644
> >>--- a/libavfilter/vf_subtitles.c
> >>+++ b/libavfilter/vf_subtitles.c
> >>@@ -54,6 +54,7 @@ typedef struct {
> >>      uint8_t rgba_map[4];
> >>      int     pix_step[4];       ///< steps per pixel for each plane of the main output
> >>      int original_w, original_h;
> >>+    int line_spacing;
> >>      FFDrawContext draw;
> >>  } AssContext;
> >>@@ -64,6 +65,7 @@ typedef struct {
> >>      {"filename",       "set the filename of file to read",                         OFFSET(filename),   AV_OPT_TYPE_STRING,     {.str = NULL},  CHAR_MIN, CHAR_MAX, FLAGS }, \
> >>      {"f",              "set the filename of file to read",                         OFFSET(filename),   AV_OPT_TYPE_STRING,     {.str = NULL},  CHAR_MIN, CHAR_MAX, FLAGS }, \
> >>      {"original_size",  "set the size of the original video (used to scale fonts)", OFFSET(original_w), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL},  CHAR_MIN, CHAR_MAX, FLAGS }, \
> >>+    {"line_spacing",   "set the height of the line spacing",                       OFFSET(line_spacing), AV_OPT_TYPE_INT,      {.i64 = 0},     INT_MIN,  INT_MAX,  FLAGS }, \
> >>  /* libass supports a log level ranging from 0 to 7 */
> >>  static const int ass_libavfilter_log_level_map[] = {
> >>@@ -139,6 +141,8 @@ static int config_input(AVFilterLink *inlink)
> >>      if (ass->original_w && ass->original_h)
> >>          ass_set_aspect_ratio(ass->renderer, (double)inlink->w / inlink->h,
> >>                               (double)ass->original_w / ass->original_h);
> >>+    if (ass->line_spacing)
> >>+        ass_set_line_spacing(ass->renderer, (double)ass->line_spacing);
> >>      return 0;
> >>  }
> >Why this setting only and not the others? libass has various others
> >customizations possible.
> 
> A user on #ffmpeg had this problem:
> http://oi40.tinypic.com/e0pgkl.jpg . Is there another useful feature
> missing ?
> 

I don't know, but it seems there are quite some configuration settings
that could be set:

    % grep 'void ass_set_' /usr/include/ass/ass.h
    void ass_set_fonts_dir(ASS_Library *priv, const char *fonts_dir);
    void ass_set_extract_fonts(ASS_Library *priv, int extract);
    void ass_set_style_overrides(ASS_Library *priv, char **list);
    void ass_set_message_cb(ASS_Library *priv, void (*msg_cb)
    void ass_set_frame_size(ASS_Renderer *priv, int w, int h);
    void ass_set_shaper(ASS_Renderer *priv, ASS_ShapingLevel level);
    void ass_set_margins(ASS_Renderer *priv, int t, int b, int l, int r);
    void ass_set_use_margins(ASS_Renderer *priv, int use);
    void ass_set_aspect_ratio(ASS_Renderer *priv, double dar, double sar);
    void ass_set_font_scale(ASS_Renderer *priv, double font_scale);
    void ass_set_hinting(ASS_Renderer *priv, ASS_Hinting ht);
    void ass_set_line_spacing(ASS_Renderer *priv, double line_spacing);
    void ass_set_line_position(ASS_Renderer *priv, double line_position);
    void ass_set_fonts(ASS_Renderer *priv, const char *default_font,
    void ass_set_cache_limits(ASS_Renderer *priv, int glyph_max,

How relevant they are, I don't know. The patch in itself is fine, It's
just too bad not to port a bunch of others settings.

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130521/e3b83b71/attachment.asc>


More information about the ffmpeg-devel mailing list