1

I'm using ffmpeg library to draw text on video in specific time and i'm success to do that Now i need to move the text from position to another and i can't do that so can any one suggest me how to do that

i'm using this command to move text from top to down but i can't determine the x and Y to move from the x,y to specific x,y

ffmpeg -i VideoInput.mp4 -vf "drawtext=enable='between(t,12,14)':fontfile=myfont.otf:text='Test test':x=(w-text_w)/2:y=w/50\*mod(t\,2):fontsize=65" -acodec copy outputVideo.mp4
BOB
  • 57
  • 4
  • 14

1 Answers1

8

Use

ffmpeg -i VideoInput.mp4 \
       -vf "drawtext=enable='between(t,12,14)':fontfile=myfont.otf:text='Test test': \
           x='x1+(x2-x1)*(t-t1)/(t2-t1)':y='y1+(y2-y1)*(t-t1)/(t2-t1)':fontsize=65" \
       -acodec copy outputVideo.mp4

where

x1 and y1 are initial co-ordinates; x2 and y2 are final co-ordinates; t1 and t2 are start and end times; in your given command, 12 and 14.

These above need to be replaced with their values in the command.


To give a 1 second stay at the end,

ffmpeg -i VideoInput.mp4 \
       -vf "drawtext=enable='between(t,12,15)':fontfile=myfont.otf:text='Test test': \
           x='if(lt(t-t2+1\,0)\,x1+(x2-x1)*(t-t1)/(t2-t1-1)\,x)': \
           y='if(lt(t-t2+1\,0)\,y1+(y2-y1)*(t-t1)/(t2-t1-1)\,y)':fontsize=65" \
       -acodec copy outputVideo.mp4

Here t2 includes the stay, so movement from 12 to 14 + 1 second hold. The t2 in enable is changed as well.

Gyan
  • 85,394
  • 9
  • 169
  • 201
  • Thanks it's works fine for me, but i have another question if you can answer it, after the end time the text disappear can i make it stay visible for 1 sec with no move then it disappear – BOB Apr 08 '16 at 14:23
  • Hello my friend i want to know one more info about moving text using ffmpeg can i control the speed of moving text? because i want to speed it up i'm trying to google it but i can found the solution so if you have any idea please help Thansk – BOB May 07 '16 at 01:48
  • Change the stay value `1` e.g. if you want the motion to occur from 12 to 13, then change `1`s to `2`s so `lt(t-t2+1\,0)` becomes `lt(t-t2+2\,0)`. Same for all other expressions in the command. – Gyan May 07 '16 at 04:34