Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg drawbox on a given frame

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?

like image 649
cédric Avatar asked Jun 27 '13 09:06

cédric


1 Answers

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
like image 54
llogan Avatar answered Oct 31 '22 14:10

llogan