As the title says: weird problem. I've been struggling to make this work for a whole day but to no avail. Any help would be deeply appreciated.
# I've tried every one of the below path but still errors: Fontconfig error: Cannot load default config file: No such file: (null)
FONT_LOC = r'C\\:/Users/acer/AppData/Local/Microsoft/Windows/Fonts/jf-openhuninn-1.1.ttf'
FONT_LOC = 'C:/Users/acer/AppData/Local/Microsoft/Windows/Fonts/jf-openhuninn-1.1.ttf'
FONT_LOC = 'C://Users/acer/AppData/Local/Microsoft/Windows/Fonts/jf-openhuninn-1.1.ttf'
duration = '30
subtitle='abc'
comd = [
"ffmpeg",
"-f", "lavfi",
"-i", "color=c=black:s=1280x720:d={duration}".format(duration=duration),
"-vf", f'''drawtext=fontfile="{FONT_LOC}":text='{subtitle}':fontcolor=white:fontsize=24:x=(w-text_w)/2:y=(h-text_h)/2''',
"-c:v", "libx264",
"-t", duration,
"-pix_fmt", "yuv420p",
output_file+'.mp4'
]
print(' '.join(comd))
subprocess.run(comd, check=True, capture_output=True, text=True) # Failed
# The below command runs successfully in the terminal.
# ffmpeg -f lavfi -i color=c=black:s=1280x720:d=2.352000 -vf drawtext=fontfile="C\\://Users/acer/AppData/Local/Microsoft/Windows/Fonts/jf-openhuninn-1.1.ttf":text='abc':fontcolor=white:fontsize=24:x=(w-text_w)/2:y=(h-text_h)/2 -c:v libx264 -t 2.352000 -pix_fmt yuv420p output_Test-0004.mp3.mp4
I expect the subprocess.run() would produce the same result. I've tried all versions of paths (different kind of escaping) but none of the aforementioned one worked.