How to display frame number on each frame of video using ffmpeg?

I have a validation command:

ffmpeg -i in.mov -vf "drawtext=fontfile=/usr/share/fonts/ttf-bitstream-vera/Vera.ttf: x=(w-tw)/2: y=h-(2*lh)-n: fontcolor=white: fontsize=40: box=1: boxcolor=0x00000000@1 : text=" -an -y out.mov 

I want to display the frame number on each frame. However, setting the "text" variable to "n" does not help (it displays n), and% n is the newline character. What bothers me the most is that this part

 y=h-(2*lh)-n 

It works well, that is, it receives the correct value of the current frame and moves the text accordingly.

+4
source share
1 answer

Well, this function was absent in ffmpeg , but now it is. Here's how you do it:

 ...drawtext=text=%{n}:expansion=normal:fontfile=/usr/share/fonts/ttf-bitstream-vera/Vera.ttf:other_options... 

Please note that the extension should be installed in a normal state, which is now not standard, but should be the default in the future (according to the ffmpeg documentation).

+4
source

Source: https://habr.com/ru/post/1447495/


All Articles