Node-fluent-ffmpeg: Drawtext complex filter - multiple line

Created on 21 Dec 2015  路  5Comments  路  Source: fluent-ffmpeg/node-fluent-ffmpeg

Hi.

Do we have any ability to apply multiple text line for drawtext complex filter?

this._ffmpeger = ffmpeg(sourcePath + sourceFileName)
    .videoCodec('libx264')
    .format('mp4')
    .fps(localData.fps)
    .setStartTime(localData.beginTime)
    .duration(localData.duration)
    .input(localData.watermark)
    .complexFilter([
      'scale='+localData.videosize+':-2[rescaled]',
      {
        filter: 'overlay',
        options: {x: 'W-w-10', y: 'H-h-10'},
        inputs: 'rescaled',
        outputs: 'watermark'
      },
      {
        filter: 'drawtext',
        options: {
          fontfile: this.config.fontFile.path+this.config.fontFile.fileName,
          text: 'VERY LONG TEXT VERY VERY VERY VERY LOL!!!',
          fontsize: 36,
          fontcolor: 'white',
          x: '(main_w/2-text_w/2)',
          y: '(text_h/2)+15',
          shadowcolor: 'black',
          shadowx: 2,
          shadowy: 2
        },
        inputs: 'watermark',
        outputs: 'output'
      }
    ], 'output')
Off-topic / ffmpeg

Most helpful comment

Resolved.
Generated overlay image with text by node-canvas

All 5 comments

You may try using 'n', 'f' or 'v' inside the text argument. Or you may just chain multiple drawtext filters ?

'\n' not working

[Error: ffmpeg exited with code 1: Error initializing complex filters.
Invalid argument]

but in source code of drawtext filter we have a function where '\n' is available
vf_drawtext.c#548

static inline int is_newline(uint32_t c)
{
    return c == '\n' || c == '\r' || c == '\f' || c == '\v';
}

'\v' is working but without line height and I didn't found any solution how or where I could specify line-height between lines.

Or you may just chain multiple drawtext filters ?

I have some text that I should to draw above the image and I can't understand where I should place new line characters in input string because I have different input video size (hd/fullhd etc) and I don't know anything about text_w or text_h in text expansion expression

for example size of image

localData.videosize = 500

and text

text: 'VERY LONG TEXT VERY VERY VERY VERY VERY VERY VERY VERY!!!',

+
fontsize = 36

Anybody have any idea how to trim string?

Resolved.
Generated overlay image with text by node-canvas

Hi. Iam trying to add text "hi fluent ffmpeg" to my video using complex filters but I have problem with required "fontfile" property I'm using "usr/shared/fonts/dejavu/DejaVuSans-Bold.ttf" as a value for fontfile.
I got an error opening filters. Can anyone help me. Thanks in advance.

good job. mark !

Was this page helpful?
0 / 5 - 0 ratings