Using write_videofile("data/output.mp4", fps='30') should produce a video file at data/output.mp4
Moviepy throws an error TypeError: must be real number, not str from the file ffmpeg_writer.py and exits the program.
Below I have included the section of code that is responsible for actually generating and saving the video file to the disk
clipData = []
for path in clipPaths:
newClip = VideoFileClip(path)
normalClip = audio_normalize(VideoFileClip(path))
clipData.append(newClip)
finalVideo = concatenate_videoclips(clipData, method='compose')
finalVideo.write_videofile("data/output.mp4", fps='30')
clipPaths is a list of paths to the clips that I am using to make the video.I have also included the full stack trace that I get when I run the code
Moviepy - Building video data/output.mp4.
MoviePy - Writing audio in outputTEMP_MPY_wvf_snd.mp3
MoviePy - Done.
Moviepy - Writing video data/output.mp4
Traceback (most recent call last):
File "src/videoEditor.py", line 60, in <module>
globals()[sys.argv[1]]()
File "src/videoEditor.py", line 51, in GenerateVideo
finalVideo.write_videofile("data/output.mp4", fps='30')
File "<decorator-gen-55>", line 2, in write_videofile
File "/home/mwollam/.local/lib/python3.8/site-packages/moviepy/decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "<decorator-gen-54>", line 2, in write_videofile
File "/home/mwollam/.local/lib/python3.8/site-packages/moviepy/decorators.py", line 135, in use_clip_fps_by_default
return f(clip, *new_a, **new_kw)
File "<decorator-gen-53>", line 2, in write_videofile
File "/home/mwollam/.local/lib/python3.8/site-packages/moviepy/decorators.py", line 22, in convert_masks_to_RGB
return f(clip, *a, **k)
File "/home/mwollam/.local/lib/python3.8/site-packages/moviepy/video/VideoClip.py", line 300, in write_videofile
ffmpeg_write_video(self, filename, fps, codec,
File "/home/mwollam/.local/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_writer.py", line 213, in ffmpeg_write_video
with FFMPEG_VideoWriter(filename, clip.size, fps, codec = codec,
File "/home/mwollam/.local/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_writer.py", line 88, in __init__
'-r', '%.02f' % fps,
TypeError: must be real number, not str
@LvInSaNevL have you tried using a real number instead of a string here?
finalVideo.write_videofile("data/output.mp4", fps=30)
@dleitee oh my goodness that was definitely the answer! Thank you so much I was banging my head against the wall haha!
write_videofile("data/output.mp4", fps='30')
Did you get that from documentation somewhere that needs changing?
@tburrows13 I took a quick look into the whole code and didn't find any mention of fps as string.
@tburrows13 I double checked with some googling and also could not find any reference to FPS as a string, I am not 100% sure where I got that from...
Ok thanks for the feedback. The only thing that I can think of is that I think the bitrate parameter is a string (that allows things like '50k'). That might be changed in the future though, it is fairly confusing.