How to position drawtext text

19,350

Positions

  • Top left: x=0:y=0 (with 10 pixel padding x=10:y=10)
  • Top center: x=(w-text_w)/2:y=0 (with 10 px padding x=(w-text_w)/2:y=10)
  • Top right: x=w-tw:y=0 (with 10 px padding: x=w-tw-10:y=10)
  • Centered: x=(w-text_w)/2:y=(h-text_h)/2
  • Bottom left: x=0:y=h-th (with 10 px padding: x=10:y=h-th-10)
  • Bottom center: x=(w-text_w)/2:y=h-th (with 10 px padding: x=(w-text_w)/2:y=h-th-10)
  • Bottom right: x=w-tw:y=h-th (with 10 px padding: x=w-tw-10:y=h-th-10)

Full example (centered)

ffmpeg -i input.mp4 -vf "drawtext=text='Super User':x=(w-text_w)/2:y=(h-text_h)/2:fontsize=24:fontcolor=white" -c:a copy output.mp4

See drawtext filter documentation for more info.

Share:
19,350

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin almost 2 years

    I'm trying to create a video using ffmpeg but I can't get the text watermark on the bottom right corner. It appears on the middle of the video. How should I change the following command?

    -vf drawtext="fontfile=C\\:/Windows/Fonts/Arial.ttf: \
    text='Stack Overflow': fontcolor=white: fontsize=24: box=1: boxcolor=black: \
    x=(w-text_w)/2: y=(h-text_h-line_h)/2"
    
  • user924
    user924 almost 6 years
    can we dynamically change text before recording each frame?
  • Elisa Cha Cha
    Elisa Cha Cha almost 6 years
    @user924 The text position or the text content?
  • user924
    user924 almost 6 years
    Text content. I want to record timestamp (yyyy-mm-dd hh-mm-ss)
  • Elisa Cha Cha
    Elisa Cha Cha almost 6 years
    @user924 See this answer.
  • Shubham Agarwal
    Shubham Agarwal almost 6 years
    Thanks, @LordNeckbeard in person for helping me for most of my ffmpeg related queries. Have a great day!
  • Jamie Hutber
    Jamie Hutber about 5 years
    Failed to inject frame into filter network: Invalid argument -filter_complex "pad=height=ih-40:color=#71cbf4,overlay=x=w-tw-10:y=h-th-10"
  • Elisa Cha Cha
    Elisa Cha Cha about 5 years
    @JamieHutber There are too many things wrong with your command to fix it in a comment. You should make a new question. Make sure to show your full command and also include the complete log from the command.
  • Jamie Hutber
    Jamie Hutber about 5 years
    Thanks very much Logan for the very fast reply. I have managed to get it into the top right overlay=x=(main_w-overlay_w)-30:y=(main_h-overlay_h)/(main_h‌​-overlay_h)+30 I will raise a quesiton now
  • Pedro Lobito
    Pedro Lobito over 4 years
    Thank you, but you actually missed the one I wanted, bottom center ;)
  • Pedro Lobito
    Pedro Lobito over 4 years
    You Rock! Thank you!