here is the part of my script where i used to attach subtitles to video:
def attach_subtitles(video: VideoFileClip) -> None:
if not os.path.exists(OUTPUT_SRT):
print("No subtitle file found")
return
print("Attaching subtitles to video...")
# Create subtitle clips
subtitles = SubtitlesClip(
OUTPUT_SRT,
lambda txt: TextClip(
txt,
font="Arial",
fontsize=24,
color="white",
bg_color="black",
)
)
# Combine video with subtitles
video_with_subtitles = CompositeVideoClip(
[
video,
subtitles.with_position(("center", 0.95), relative=True)
]
)
# Write output video
print("Rendering final video...")
video_with_subtitles.write_videofile(
OUTPUT_VID,
codec="libx264",
audio_codec="aac"
)
print(f"Video saved as {OUTPUT_VID}")
and i keeps getting this error:
An error occurred: Invalid font <function attach_subtitles.<locals>.<lambda> at 0x00000202C5FCF600>, pillow failed to use it with error 'function' object has no attribute 'read'
i have tried many different fonts but the problem still persists