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

余生长醉 提交于 2019-12-10 17:04:46

问题


The test command I have is as follows:

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 seems to be the new line symbol. The thing that confuses me most is that this part

y=h-(2*lh)-n

works well, meaning it gets the right value of the current frame and moves the text up accordingly.


回答1:


Ok, this feature was not there in ffmpeg, but now it is. And this is how you do it:

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

Note that expansion should be set to normal, which is not the default now, but should be default in the future (according to the ffmpeg documentation).



来源:https://stackoverflow.com/questions/13494902/how-to-display-a-frame-number-on-each-frame-of-a-video-using-ffmpeg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!