ffmpeg - 如何叠加多个旋转的文本和视频

时间:2017-11-10 08:11:00

标签: ffmpeg

我有ffmpeg的命令来旋转一个文本并将其叠加到我的视频上,但是如果我有多个要旋转的文本怎么办呢?

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=30:ow=rotw(30):oh=roth(30):c=black@0[txta]; \
[mv][txta]overlay=x='min(0,-H*sin(30))+100':y='min(0,W*sin(30))+50':shortest=1" \
output_video.mp4

1 个答案:

答案 0 :(得分:0)

假设您有三个要处理的文本,那么。

ffmpeg -i input1.mp4 -filter_complex \
"color=black:100x100[c]; \
[c][0]scale2ref[ct][mv]; \
[ct]setsar=1,split=3[t1][t2][t3]; \
[t1]drawtext=fontfile=../../public/fonts/Roboto-Regular-webfont.ttf: \
text='Test Text 1':fontsize=36:fontcolor=white,split[text1][alpha1]; \
[text1][alpha1]alphamerge,rotate=30:ow=rotw(30):oh=roth(30):c=black@0[txta1]; \
[t2]drawtext=fontfile=../../public/fonts/Roboto-Regular-webfont.ttf: \
text='Test Text 2':fontsize=36:fontcolor=white,split[text2][alpha2]; \
[text2][alpha2]alphamerge,rotate=45:ow=rotw(45):oh=roth(45):c=black@0[txta2]; \
[t3]drawtext=fontfile=../../public/fonts/Roboto-Regular-webfont.ttf: \
text='Test Text 3':fontsize=36:fontcolor=white,split[text3][alpha3]; \
[text3][alpha3]alphamerge,rotate=60:ow=rotw(60):oh=roth(60):c=black@0[txta3]; \
[mv][txta1]overlay=x='min(0,-H*sin(30))+100':y='min(0,W*sin(30))+50':shortest=1[mv1]; \
[mv1][txta2]overlay=x='min(0,-H*sin(45))+100':y='min(0,W*sin(45))+50':shortest=1[mv2]; \
[mv2][txta3]overlay=x='min(0,-H*sin(60))+100':y='min(0,W*sin(60))+50':shortest=1" \
output_video.mp4

您可能需要调整叠加坐标以避免重叠。