ffmpeg drawbox on a given frame

10,719

The drawbox video filter has timeline editing support. You can see what filters support timeline editing:

$ ffmpeg -filters
…
Filters:
  T. = Timeline support
  .S = Slice threading
  A = Audio input/output
  V = Video input/output
  N = Dynamic number and/or type of input/output
  | = Source or sink filter
…
 .. deshake          V->V       Stabilize shaky video.
 T. drawbox          V->V       Draw a colored box on the input video.
 T. drawgrid         V->V       Draw a colored grid on the input video.

You can see that drawbox and drawgrid have timeline support, but deshake currently does not.

Usage example. This will place the red box from frames 28-32, and the green box starting at 60 seconds. Also see the documentation on expression evaluations for additional functions.

ffmpeg -i small.ts -vf "drawbox=enable='between(n,28,32)' : x=10 : y=10 : w=50 \
: h=50 : color=red,drawbox=enable='gte(t,60)' : x=100 : y=100 : w=200 : \
h=200 : color=green" -codec:a copy small_with_box.ts
Share:
10,719

Related videos on Youtube

cédric
Author by

cédric

Updated on June 29, 2022

Comments

  • cédric
    cédric about 2 years

    I have thousands of rectangle boxes to add in a video. Right now I am using this command:

    ffmpeg.exe -i small.ts -vf drawbox=10:10:50:50:red,drawbox=100:100:200:200:green small_with_box.ts
    

    However I don't want to add the boxes on an entire frame, but on a given one. Anyone know how can I do that?

  • dgolovin
    dgolovin over 2 years
    Expression Evaluation documentation ffmpeg.org/ffmpeg-utils.html#toc-Expression-Evaluation