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

Rainer M Krug Rainer at krugs.de
Thu Apr 8 12:13:21 EEST 2021



> On 8 Apr 2021, at 10:23, Michael Koch <astroelectronic at t-online.de> wrote:
> 
> 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

Yes it is

> and constant in all frames.

No it isn’t.
But I should be able to extend the number of particles by plotting with size 0 or outside the frame?


> Use several drawtext commands, one for each particle.

So I would have for each particle and each frame, a draw text command in the command,txt file which is read using the sendcmd command - is this correct?

Final point: how can I specify the frame as the start-end? I only fsaw in the documentation how to specify the time?

> 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 <http://www.astro-electronic.de/FFmpeg_Book.pdf>

Thanks for the link - I will loo into it, and it looks definitely useful!

Rainer

> 
> Michael
> 
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org <mailto:ffmpeg-user at ffmpeg.org>
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user <https://ffmpeg.org/mailman/listinfo/ffmpeg-user>
> 
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org <mailto:ffmpeg-user-request at ffmpeg.org> with subject "unsubscribe".

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Zürich
Office Y34-J-74
Winterthurerstrasse 190
8075 Zürich
Switzerland

Office:	+41 (0)44 635 47 64
Cell:       	+41 (0)78 630 66 57
email:      Rainer.Krug at uzh.ch
		Rainer at krugs.de
Skype:     RMkrug

PGP: 0x0F52F982



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4372 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-user/attachments/20210408/b4d21696/attachment.bin>


More information about the ffmpeg-user mailing list