Search code examples
ffmpeg

How to rotate only the text in ffmpeg and not the whole video


am using this command to put text on a video

/usr/bin/ffmpeg -i $urlVideo $startFlags 'drawtext=fontfile=$font:text=$text:fontcolor=$color:x=$x: y=$y: fontsize=$size$enable' $endFlags " . $resultFilePath

so i added the rotate argument to rotate a text (rotate=0.3). so the result was that the hole file was rotated. how to rotate only the text? thank you.

PS:am so new to ffmpeg :3


Solution

  • Here is a -vf option expression example:

    color=c=black@0,drawtext=text=Test Text:x=w/2:y=h/2,rotate=PI/6:fillcolor=black@0[L0];
    [in][L0]overlay=shortest=true
    

    For precise positioning, you can try:

    • size color source to match your text size.
    • let rotate to expand frame size.
    • remember rotate rotates the frame about its center
    • use overlay's x and y options to place the text in its final position