question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Concatenation with TextClip and VideoFileClip results in unplayable video, MoviePy 1.0.3

See original GitHub issue

Expected Behavior

Concatenating a TextClip with a VideoFileClip should put the two clips together and be playable.

Actual Behavior

Concatenating a TextClip with a VideoFileClip renders an unplayable video. When opened in the Movies & TV Windows app, it simply cannot be played. When opened with Windows Media Player it also cannot be played and causes the app to become unresponsive.

Steps to Reproduce the Problem

  • Initialize virtual environment and install moviepy=1.0.3
  • Download Windows ImageMagick-7.0.10-Q16-HDRI
  • Set binary locations for ffmpeg and ImageMagick in config_defaults.py
  • Run the following code
from moviepy.editor import *

first_five_seconds = VideoFileClip('./videos/2019-10-18.mp4').subclip(0, 5)
first_five_seconds.write_videofile('./clips/first_five_seconds.mp4')

title = TextClip('Title', fontsize=75, color='green')
title = title.set_position('bottom').set_duration(4)

with_title_screen = CompositeVideoClip([title, first_five_seconds])
with_title_screen.write_videofile('./clips/with_title_screen.mp4')
  • The first is playable while the second is unplayable

Specifications

  • Python Version: 3.8.3
  • Moviepy Version: 1.0.3
  • ImageMagick Binary Version: ImageMagick-7.0.10-Q16-HDRI
  • Platform Name: Windows
  • Platform Version: Windows 10

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
riyanWicommented, Nov 20, 2020

have same problem with TextClip and VideoFileClip with same specifications, but in my case there’s glitch in the end of the video.

0reactions
jcbrockschmidtcommented, Jan 14, 2021

Interestingly, removing with_position and font_size creates a working 36x12 video (using Moviepy version 2.0.0.dev2 at f5944d4):

from moviepy.editor import *

sub_clip = VideoFileClip("./media/big_buck_bunny_0_30.webm").subclip(0, 5)
title = TextClip("Title", color="green").with_duration(sub_clip.duration)
comp_clip = CompositeVideoClip([title, sub_clip])
comp_clip.write_videofile("./clips/with_title_screen.mp4")

What I think is happening is the section of sub_clip that overlaps with title is being shown. I experimented a bit with TextClips and found that setting the position to "bottom" often places them off screen (you usually want to use the align property for this sort of thing anyway). So perhaps in the original script the lack of overlap between first_five_seconds and title causes the compositing to break. Although, it should be noted that changing the order of title and first_five_seconds in CompositeVideoClip([...]) creates a functional video, so its more than just a lack of overlapping (if that’s even the cause).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mixing clips — MoviePy 1.0.2 documentation
Two simple ways of putting clips together is to concatenate them (to play them one after the other in a single long clip)...
Read more >
MoviePy – Concatenating multiple Video Files - GeeksforGeeks
Syntax : concatenate_videoclips(clips) ; Argument : It takes list of video file clips as argument ; Return : It returns VideoFileClip object.
Read more >
How to concatenate videos in moviepy? - Stack Overflow
import moviepy.editor as mp messages = ["Dog", "Cat", "Duck", "Wolf"] clips = [ mp.TextClip(txt, fontsize=170, color='green', ...
Read more >
movie-py/Lobby - Gitter
I know moviepy.editor.VideoFileClip gets just the video but how can I get the audio and video? ... How can I add some fancy...
Read more >
Editing Video with Python + MoviePy - Section.io
In this tutorial, we will use MoviePy, a Python library, to edit and add effects to a given video clip. This tutorial uses...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found