Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
515 views
in Technique[技术] by (71.8m points)

Using FFMPEG to create animated GIF from series of images and insert text for each image

I am generating an animated gif from a series of png's labeled img_00.png, img_01.png, etc. I want to insert text to the top right corner of the animated gif for each frame that is generated from the png to display some specific information. For example say I have 3 pngs, img_00, img_01, and img_02...what I want from the gif is:

For frame generated from img_00, display "This is from img_00". For frame generated from img_01, display "This is from img_01". For frame generated from img_02, display "This is the last image generated from img_02!".

So far I have been messing around with drawtext option (assuming framerate=1):

ffmpeg -f image2 -framerate 1 -i img_%02d.png -filter_complex "drawtext=enable='between(t,0,1)':text='word1':fontsize=24:fontcolor=white:x=w-tw:y=0,drawtext=enable='between(t,1,2)':text='word2':fontsize=24:fontcolor=white:x=w-tw:y=0" out.gif

But I am getting "word1" and "word2" overlapped on top of each other. Is there a better way of doing this or someway to fix drawtext so the overlap doesn't happen?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

between(t,0,1) and between(t,1,2) will overlap for t=1. Either the end time for the first range or the start time for the second range should be adjusted e.g. you can make the first range between(t,0,0.9).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...