视频处理

ffmpeg # drawtext 进阶

2019-03-15  本文已影响0人  FlyingPenguin

预备知识

https://ffmpeg.org/ffmpeg-utils.html

between(x, min, max)
Return 1 if x is greater than or equal to min and lesser than or equal to max, 0 otherwise.
...
gt(x, y)
Return 1 if x is greater than y, 0 otherwise.

gte(x, y)
Return 1 if x is greater than or equal to y, 0 otherwise.

...
if(x, y)
Evaluate x, and if the result is non-zero return the result of the evaluation of y, return 0 otherwise.

if(x, y, z)
Evaluate x, and if the result is non-zero return the evaluation result of y, otherwise the evaluation result of z.
...
lt(x, y)
Return 1 if x is lesser than y, 0 otherwise.

lte(x, y)
Return 1 if x is lesser than or equal to y, 0 otherwise.

...
mod(x, y)
Compute the remainder of division of x by y.

一些加文字的例子

ffmpeg -i bunny.mp4 -vf drawtext=fontcolor=white:fontsize=40:fontfile=test.ttf:line_spacing=7:text='test':x=50:y=50:enable='lte(t\,5)'   -y out.mp4
ffmpeg -i bunny.mp4 -vf drawtext=fontcolor=white:fontsize=40:fontfile=test.ttf:line_spacing=7:text='test':x=50:y=50:enable='gte(t\,5)'   -y out.mp4
ffmpeg -i bunny.mp4 -vf drawtext=fontcolor=white:fontsize=40:fontfile=test.ttf:line_spacing=7:text='test':x=50:y=50:enable='between(t\,10\,20)'   -y out.mp4
ffmpeg -i bunny.mp4 -vf drawtext=fontcolor=white:fontsize=40:fontfile=msyh.ttf:line_spacing=7:text='test':x=50:y=50:enable='between(t

+10\,0\,15)'   -y out.mp4
ffmpeg -i bunny.mp4 -vf drawtext=fontcolor=white:fontsize=40:fontfile=test.ttf:line_spacing=7:text='test':x=50:y=50:enable='lte(mod(t\,10)\,5)'   -y out.mp4
ffmpeg -i bunny.mp4 -vf drawtext=fontcolor=white:fontsize=40:fontfile=test.ttf:line_spacing=7:text='hello':x=50:y=50:enable='lte(mod(t

\,10)\,5)',drawtext=fontcolor=white:fontsize=40:fontfile=test.ttf:line_spacing=7:text='world':x=50:y=50:enable='gte(mod(t\,10)\,5)'   -y 

out.mp4
 ffmpeg -i bunny.mp4 -vf drawtext=fontcolor=white:fontsize=40:fontfile=test.ttf:line_spacing=7:text='test':x=50+n*2:y=50  -y 
out.mp4
 ffmpeg -i bunny.mp4 -vf drawtext=fontcolor=white:fontsize=20:fontfile=test.ttf:line_spacing=7:text='%{localtime}':x=20:y=20 -vframes 600  -y out.mp4

References:

http://blog.threadblocked.com/2018/06/09/post1/

上一篇 下一篇

猜你喜欢

热点阅读