I'm using FFmpeg to overlay text on videos, and I find the process to be quite slow. The operation becomes especially slow when I add complex drawtext filters. I'm running this on a MacBook Pro with M1 Pro and 32GB RAM, yet FFmpeg is using only 20% of the CPU at most. I'd like to speed up the process without compromising on quality.
Here's the FFmpeg command I'm using:
ffmpeg -i input.mp4 \
-vf "drawtext=fontfile='/path/to/font.ttf':textfile='text1.txt':\
x=(w-text_w)/2:y=(h-text_h)/2:fontsize=65:[email protected]:\
bordercolor=black:borderw=9:shadowcolor=black:shadowx=5:shadowy=5:\
box=1:[email protected]:boxborderw=20:fix_bounds=1:line_spacing=10:\
enable='between(t,0,5)',\
drawtext=fontfile='/path/to/font.ttf':textfile='text2.txt':\
x=(w-text_w)/2:y=(h-text_h)/2:fontsize=65:[email protected]:\
bordercolor=black:borderw=9:shadowcolor=black:shadowx=5:shadowy=5:\
box=1:[email protected]:boxborderw=20:fix_bounds=1:line_spacing=10:\
enable='between(t,5,10)'" \
-b:v 5000k -c:v h264_videotoolbox -threads 0 -y output.mp4
Any suggestions on how to optimize this command to better utilize the CPU and improve the speed of text overlay with FFmpeg?