[FFmpeg-user] Plotting Circles and labels on individual frames of a movie

Michael Koch astroelectronic at t-online.de
Thu Apr 8 11:23:42 EEST 2021


Am 08.04.2021 um 09:46 schrieb Rainer M Krug:
> Hi
>
> I have a series of videos of moving particles (multiple particles per frame / movie), and would like to add a circle around each particle and add a label. At the moment I am using a script in R to plot, for each frame, these circles and labels into a png with alpha channel, combine the pngs to a movie, and overlay this movie to the original movie (see the thread 'Overlay images to frames in video’ for the background).
>
> Now I realised, that the actual plotting of the labels takes up nearly 40% of the time of the R script and I would like to make this process faster.
>
> I have found “draw_text” (https://ffmpeg.org/ffmpeg-filters.html#drawtext), but I have no idea how I could do this. We can assume that I have a text file with the following columns:
>
> FRAME: the frame on which the labels and circle should be plotted
> X:     the x-coordinate
> Y:     the y=coordinate
> LABEL: label for the point
>
> Also possibly important, there are multiple (many) particles for which circles and labels need to be plotted on each frame.
>
> I also found the “sendcmd” (https://ffmpeg.org/ffmpeg-filters.html#sendcmd_002c-asendcmd) but I do not get my head around how I can combine these two.

It's possible to do this with FFmpeg if the number of particles is known 
in advance and constant in all frames. Use several drawtext commands, 
one for each particle. But with a changing number of particles I have no 
idea how to do it. There are a few examples for sendcmd in chapter 2.86 
of my book:
http://www.astro-electronic.de/FFmpeg_Book.pdf

Michael



More information about the ffmpeg-user mailing list