0

What I am trying to do is to add a short text at specific timeframe of a mp4 video. I have this code:

# Import everything needed to edit video clips 
from moviepy.editor import *
    
# loading video dsa gfg intro video 
clip = VideoFileClip("video.mp4") 
    
# clipping of the video  
# getting video for only starting 10 seconds 
clip = clip.subclip(0, 5) 
    
# Reduce the audio volume (volume x 0.8) 
clip = clip.volumex(0.8) 

text = "Hello world!"

# Generate a text clip 
txt_clip = TextClip(text, fontsize = 75, color = 'black') 

    
# setting position of text in the center and duration will be 10 seconds 
txt_clip = txt_clip.set_pos('center').set_duration(2).set_start(3) 

# Overlay the text clip on the first video clip 
video = CompositeVideoClip([new_clip, txt_clip]) 
    
# showing video 
video.ipython_display(width = 280) 

Everything works well except that the text changes suddenly to something like '@/tmp/tmpq5b_zzvf.txt' which is obviously not the intended effect.

Beside googling, I tried dir(txt_clip) to see if I could change it manually, and it does have a txt attribute associated with it. but inserting txt_clip.txt = "Hello world" right afterward does not do anything.

What could be the culprit?

0 Answers0