I get the error "TypeError: 'int' object is not iterable" when I try to add a TextClip to a Video Clip.
For my application I need to extract a short section of video and then sometimes join it to another short section of video. Then finally I want to add a textclip on top of the entire video.
I was also getting the issue 863, but removing the audio (which luckily I don't need) resolved that. Although I have found that running the same code with the same video source files this issue comes and goes.
I am doing my testing with two video clips shot on the same camera, with same resolution etc.
Running on Windows 10, I have tried Python 3.11 and 3.8.10
I have also played around with text on top of image files using moviepy and have no problems getting that to work correctly.
If I uncomment either of the last two lines in the code below I get the following error. The reference to "JunkYard" below is just a pycharm project that I try things out in. Saves messing up my actual project code.
Traceback (most recent call last):
File "C:\Users\keith\OneDrive\python\JunkYard\moviepy\video_text.py", line 27, in
final_video.write_videofile('final_video.mp4')
File "", line 2, in write_videofile
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, k)
File "", line 2, in write_videofile
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\decorators.py", line 135, in use_clip_fps_by_default
return f(clip, *new_a, *new_kw)
File "", line 2, in write_videofile
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\decorators.py", line 22, in convert_masks_to_RGB
return f(clip, a, k)
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\video\VideoClip.py", line 300, in write_videofile
ffmpeg_write_video(self, filename, fps, codec,
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\video\io\ffmpeg_writer.py", line 220, in ffmpeg_write_video
for t,frame in clip.iter_frames(logger=logger, with_times=True,
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\Clip.py", line 472, in iter_frames
frame = self.get_frame(t)
File "", line 2, in get_frame
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\decorators.py", line 89, in wrapper
return f(*new_a, **new_kw)
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\Clip.py", line 93, in get_frame
return self.make_frame(t)
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\video\compositing\CompositeVideoClip.py", line 111, in make_frame
f = c.blit_on(f, t)
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\video\VideoClip.py", line 546, in blit_on
pos = list(pos)
TypeError: 'int' object is not iterable
from moviepy.editor import *
import pygame
path = 'moviepy/'
c = VideoFileClip(f'swim1.mp4').subclip(0, 2)
c = c.without_audio()
c.preview()
d = VideoFileClip('swim2.mp4').subclip(0, 2)
d = d.without_audio()
d.preview()
text = TextClip('Testing Testing Testing', fontsize=40, color='red').set_position(100, 100).set_duration(2)
text.preview()
final_clips = concatenate_videoclips([d, c])
final_clips.preview()
final_clips.write_videofile('final_clips.mp4')
final_video = CompositeVideoClip([final_clips, text])
# Uncomment either of the next two lines and I get the error
#final_video.write_videofile('final_video.mp4')
#final_video.preview()
I get the error "TypeError: 'int' object is not iterable" when I try to add a TextClip to a Video Clip.
For my application I need to extract a short section of video and then sometimes join it to another short section of video. Then finally I want to add a textclip on top of the entire video.
I was also getting the issue 863, but removing the audio (which luckily I don't need) resolved that. Although I have found that running the same code with the same video source files this issue comes and goes.
I am doing my testing with two video clips shot on the same camera, with same resolution etc.
Running on Windows 10, I have tried Python 3.11 and 3.8.10
I have also played around with text on top of image files using moviepy and have no problems getting that to work correctly.
If I uncomment either of the last two lines in the code below I get the following error. The reference to "JunkYard" below is just a pycharm project that I try things out in. Saves messing up my actual project code.
Traceback (most recent call last): File "C:\Users\keith\OneDrive\python\JunkYard\moviepy\video_text.py", line 27, in
final_video.write_videofile('final_video.mp4')
File "", line 2, in write_videofile
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, k)
File "", line 2, in write_videofile
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\decorators.py", line 135, in use_clip_fps_by_default
return f(clip, *new_a, *new_kw)
File "", line 2, in write_videofile
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\decorators.py", line 22, in convert_masks_to_RGB
return f(clip, a, k)
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\video\VideoClip.py", line 300, in write_videofile
ffmpeg_write_video(self, filename, fps, codec,
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\video\io\ffmpeg_writer.py", line 220, in ffmpeg_write_video
for t,frame in clip.iter_frames(logger=logger, with_times=True,
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\Clip.py", line 472, in iter_frames
frame = self.get_frame(t)
File "", line 2, in get_frame
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\decorators.py", line 89, in wrapper
return f(*new_a, **new_kw)
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\Clip.py", line 93, in get_frame
return self.make_frame(t)
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\video\compositing\CompositeVideoClip.py", line 111, in make_frame
f = c.blit_on(f, t)
File "C:\Users\keith\OneDrive\python\JunkYard\venv\lib\site-packages\moviepy\video\VideoClip.py", line 546, in blit_on
pos = list(pos)
TypeError: 'int' object is not iterable