how to draw n number of rectangles on video with ffmpeg

0

Im trying to create a video for testing framrate html5 players this video need to contain rectanges for each frame for the first 10 frames i need it to be dynamic.

for now i have the following command:

ffmpeg -loop 1 -i black.png -c:v libx264 -t 15 -r 30 -vcodec h264 -pix_fmt yuv420p \
       -vf "[in]drawtext=fontfile=/usr/share/fonts/open-sans/OpenSans-Regular.ttf : text=%{n}:x=(w-tw): y=h-(lh): fontcolor=white: box=1: boxcolor=0x00000099, \
            drawbox=x='mod(t\,10)*32':w=16:h=16:color=white@1[out]" \
       -y out123.mp4

again im trying to draw a rectangle for each frame in the to image like so: x=16*0,x=16*1,x=16*2...

the only mving pate here is the x param and its not moving can any one help?

loops
ffmpeg
draw
asked on Stack Overflow Oct 29, 2017 by taltal115 • edited Oct 29, 2017 by Gyan

1 Answer

1

The expressions in drawbox can't refer to time. Overlay the box instead:

ffmpeg -loop 1 -i black.png -filter_complex \
   "drawtext=fontfile=/usr/share/fonts/open-sans/OpenSans-Regular.ttf:text=%{n}:x=(w-tw):y=h-(lh):fontcolor=white:box=1:boxcolor=0x00000099[txt]; \
    color=white:s=16x16:r=30:d=0.35[box]; \
    [txt]box]overlay=x='16*n':y=0:enable='lt(n,10)'" \
  -c:v libx264 -t 15 -r 30 -vcodec h264 -pix_fmt yuv420p -y out123.mp4

This will overlay the box at x=0,16,32,48.. for first 10 frames and then disappear.

Note that the input image is being interpreted as 25 fps, so by setting -r 30, one frame will be duplicated every 5 input frames. Add -framerate 30 before -i black.png and drop -r 30 to avoid this.

answered on Stack Overflow Oct 29, 2017 by Gyan

User contributions licensed under CC BY-SA 3.0