Concatenating VideoFileClip is too slow
See original GitHub issueIn our django project we are receiving a text from the user and integrating the text to 6 different parts of the the video. Below is the code we are using. It is very slow, takes more than 1 minute to load the page. Is there any way to load it faster ?
def videoView(request):
if request.method == "POST":
brand=request.POST["brand"]
video = VideoFileClip("video.mp4").subclip(0,3)
txt_clip = ( TextClip(brand,fontsize=40,color='black', font="Helvetica-Bold")
.set_position((1325,670))
.set_duration(3) )
result1 = CompositeVideoClip([video, txt_clip])
video = VideoFileClip("video.mp4").subclip(3.01,6)
txt_clip = ( TextClip(brand,fontsize=40,color='black')
.set_position((450,450))
.set_duration(3) )
result2 = CompositeVideoClip([video, txt_clip]) # Overlay text on video
video = VideoFileClip("video.mp4").subclip(6.01,9)
txt_clip = ( TextClip(brand,fontsize=40,color='black')
.set_position((1305,590))
.set_duration(3) )
result3 = CompositeVideoClip([video, txt_clip]) # Overlay text on video
video = VideoFileClip("video.mp4").subclip(9.01,12)
txt_clip = ( TextClip(brand,fontsize=40,color='black')
.set_position((1235,520))
.set_duration(3) )
result4 = CompositeVideoClip([video, txt_clip]) # Overlay text on video
video = VideoFileClip("video.mp4").subclip(12.01,15)
txt_clip = ( TextClip(brand,fontsize=40,color='black')
.set_position((470,500))
.set_duration(3) )
result5 = CompositeVideoClip([video, txt_clip]) # Overlay text on video
video = VideoFileClip("video.mp4").subclip(15.01,18.08)
txt_clip = ( TextClip(brand,fontsize=40,color='black')
.set_position((1250,510))
.set_duration(3) )
result6 = CompositeVideoClip([video, txt_clip]) # Overlay text on video
result = concatenate([result1, result2, result3, result4, result5, result6]) # Overlay text on video
result.resize(width=480).write_videofile("media/{}.webm".format(brand) ,
fps=5,threads=4,logger=None, audio=False) # Many options...
else:
brand=None
print("Sorry,Something went wrong.")
return render(request, 'video/video_display.html',{'brand':brand})
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Concat videos too slow using Python MoviePY - Stack Overflow
Is there anyway I can speed this process up ? padding = 10 # padding option video_clips = [VideoFileClip(video_dir + video) for video...
Read more >combine list of video into single video ffmpeg-python - Reddit
I am trying to trying to combine a list of multiple videos into one video file. Currently I am using moviepy which is...
Read more >How to be efficient with MoviePy
Press Escape abort the previewing. Note that if the clip is complex and your computer not fast enough, the preview will appear slowed...
Read more >Solved: Python Error - Experts Exchange
Hi Guys I'm using Python 3.8.1 and below is a script I use import glob import numpy as np # for numerical operations...
Read more >Moviepy TextClip
from moviepy.editor import VideoFileClip, concatenate_videoclips Define two ... the merging of two videos is possible using Python and that too without any ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am also experiencing prohibitively slow video-writing. See below for simple code example – 10 second clip with low-def resolution, 1FPS, ultrafast setting takes 40 seconds to render. This is on a computer with 4.0 GHz, 4 core CPU & 32GB RAM.
Closing this issue as we haven’t heard back from OP since 2019 and the suggestions above sound like useful workarounds.