1:先要配置ffmpeg的滤镜:
参考: https://www.jianshu.com/p/9d24d81ca199
执行命令:./configure --enable-shared --enable-libfreetype --enable-libfribidi --prefix=/monchickey/ffmpeg
如果爆出如下错误:
freetype2 not found using pkg-config
参考如下文档: https://blog.csdn.net/zb774095236/article/details/94002623
并且完成安装之后要执行: cp /usr/local/freetype/lib/pkgconfig/freetype2.pc /usr/share/pkgconfig/

之后就可以进行水印的生成了: https://www.jianshu.com/p/9d24d81ca199

我用的命令是:
ffmpeg -i input.mp4 -vf "drawtext=fontfile=simhei.ttf: text='技术是第一生产力':x=(w-tw)/2:y=(h-th)/2:fontsize=350:fontcolor=0x7b7b7b45@0x00:shadowy=1" output.mp4

详细参数参考下面文档:https://ffmpeg.org/ffmpeg-utils.html#color-syntax
颜色对应表: https://www.runoob.com/html/html-colorvalues.html

压缩+水印+分片一条龙:

 /monchickey/ffmpeg/bin/ffmpeg  -i  $vurl -preset ultrafast -vf "drawtext=fontfile=/freedombase/freedomcontent/font/simhei.ttf: text='"$watertitle"':x=(w-tw)/2:y=(h-th)/2:fontsize=h/10:alpha=0.4:fontcolor=0x7b7b7b45@0x4D:shadowy=1"  -y  -qscale 0 -s 1280x720 -vcodec h264 -strict -2 -c:v libx264 -c:a aac -f hls -hls_list_size 0 -hls_time 5 $qurl