Search code examples
ffmpegdrawdrawtext

FFmpeg drawtext on a range of frames


drawtext option has a 'draw' expression that specifies if the text should be drawn. http://www.ffmpeg.org/ffmpeg-filters.html#drawtext-1

I figured out we could use the following expressions to write on, before, or after a specific frame:

:draw='eq(n,42)', :draw='lt(n,42)', :draw='gt(n,42)'

Do you know how to combine two expressions to write text, for instance, on every frame between frames 10 and 42 ?

I've asked ffmpeg and searched doc or examples for combining expressions. The following don't work:

:draw='gt(n,10)&&lt(n,42)' -> crash
:draw='gt(n,10);lt(n,42)' -> only applies second expression
:draw='gt(n,10)':draw='lt(n,42)' -> only applies second expression

I'm using ffmpeg version 0.8.6-4:0.8.6-0ubuntu0.12.04.1

Thanks in advance


Solution

  • OK, I've just found the answer on an ffmpeg forum and got helped by an ffmpeg dev.

    Both expressions work fine for me:

    draw='gt(n,10)*lt(n,42)'
    draw='if(gt(n,10),lt(n,42))'
    

    More info here: http://ffmpeg.org/ffmpeg-all.html#Expression-Evaluation