【ffmpeg】ffmpeg视频添加水印并解决字体问题Could not load font "FreeSerif.ttf":cannot opencv resource

解决字体问题Could not load font "FreeSerif.ttf":cannot opencv resource

[root@localhost test]# ffmpeg -i 123.mp4 -vf "drawtext=fontsize=100:fontfile=FreeSerif.ttf:text='Hello World':x=20:y=20" output02.mp4

报错

[Parsed_drawtext_0 @ 0x12006fff0] Could not load font "FreeSerif.ttf": cannot open resource

[AVFilterGraph @ 0x12006f010] Error initializing filter 'drawtext' with args 'fontsize=100:fontfile=FreeSerif.ttf:text=Hello World:x=20:y=20'

Error opening filters!

去官网下载字体

http://font.downloadatoz.com/download,33689,freeserif.html

解压后

查看字体文件当前位置

[root@localhost freeserif-1333163334]# pwd
/root/桌面/ffmpeg/freeserif-1333163334

添加字体水印

ffmpeg -i 123.mp4 -vf "drawtext=fontsize=100:fontfile=/root/桌面/ffmpeg/freeserif-1333163334/FreeSerif.ttf:text='Hello World':fontcolor=red:box=1:boxcolor=yellow:x=20:y=20"  -strict -2  output5.mp4

播放

[root@localhost test]# ffplay output5.mp4 

发布了201 篇原创文章 · 获赞 46 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/rong11417/article/details/104610077