Overlaying text on video with required angle using FFMPEG -


i trying overlay text on video using ffmpeg. able overlay text bellow command.

ffmpeg -i input1.mp4 -filter_complex "[0:v]transpose=2[anticlockwiserotated];[anticlockwiserotated]drawtext=fontfile=../../public/fonts/roboto-regular-webfont.ttf: text='test text':x=100: y=50: fontsize=36: fontcolor=white:[textapplied];[textapplied]transpose=1" output_video.mp4 

it allowing me overlay horizontally or vertically only.

but want append angle 45 degrees.

for if modify command as

ffmpeg -i input1.mp4 -filter_complex "[0:v]rotate=45*pi/180[anticlockwiserotated];[anticlockwiserotated]drawtext=fontfile=../../public/fonts/roboto-regular-webfont.ttf: text='test text':x=100: y=50: fontsize=36: fontcolor=white:[textapplied];[textapplied]rotate=315*pi/180" output_video.mp4 

by getting overlay video as:

enter image description here

because in first rotating video 45 degrees, appending text , bringing original position. loosing borders.

please suggest me best way overlay text required angle on video.

thanks in advance.

basic method generate text on blank canvas, alpha layer text, rotating result , overlaying on main video.

in command below, a should replaced angle. co-ordinates drawtext used in overlay instead. depending on length of text, of may clipped if you've rotated anticlockwise. check , adjust y offset accordingly.

ffmpeg -i input1.mp4 -filter_complex          "color=black:100x100[c];          [c][0]scale2ref[ct][mv];          [ct]setsar=1,drawtext=fontfile=../../public/fonts/roboto-regular-webfont.ttf:              text='test text':fontsize=36:fontcolor=white,split[text][alpha];          [text][alpha]alphamerge,rotate=a:ow=rotw(a):oh=roth(a):c=black@0[txta];          [mv][txta]overlay=x='min(0,-h*sin(a))+100':y='min(0,w*sin(a))+50':shortest=1"       output_video.mp4 

Comments

Popular posts from this blog

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -

testing - Detect whether test has failed within fixture -

android - Create single AAR file from multiple modules using Gradle -