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
925 views
in Technique[技术] by (71.8m points)

ffmpeg - Making jumping text watermark

I want to make something like these : http://www.youtube.com/watch?v=AtM-f20XV4E you can see there a watermark which change position every two second...

But I need it for drawtext filter.

So, I am already realize how to change a text position every few seconds.. but have no idea - how to keep new position :) there is a code which I have right now..

ffmpeg.exe -i myVideo.mov -c:v libx264 -preset veryfast -crf 25 -tune zerolatency -vendor ap10 -pix_fmt yuv420p -filter:v drawtext=fontfile=arial.ttf:text=MY_WATERMARK_TEXT:fontcolor=white:alpha=0.5:fontsize=74:box=1:boxcolor=red:x=if(eq(mod(t,1),0),1000,10):y=(h-text_h-line_h)/2 -c:a copy outVideo.mp4

it move my text to new position every 1 second. but then immediately change position back of course.

So, I stuck about that.. how to keep new position ? may be I should using ld() and st() ?

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

Ok. It was easier than I thought..

There is an answer:

ffmpeg.exe -i myVideo.mov -c:v libx264 -preset veryfast -crf 25 -tune zerolatency -vendor ap10 -pix_fmt yuv420p -filter:v drawtext=fontfile=arial.ttf:text=MY_WATERMARK_TEXT:fontcolor=white:alpha=0.5:fontsize=74:box=1:boxcolor=red:x=if(eq(mod(n,18),0),sin(random(1))*w,x):y=if(eq(mod(n,18),0),sin(random(1))*h,y) -c:a copy outVideo.mp4

That's a primary part:

x=if(eq(mod(n,18),0),sin(random(1))*w,x):

y=if(eq(mod(n,18),0),sin(random(1))*h,y)

In this example Text_Watermark will change position to random one in every 18'nth frame.


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

...