Open whimxiqal opened 3 years ago
have same problem with TextClip and VideoFileClip with same specifications, but in my case there's glitch in the end of the video.
Thanks for the report. Unfortunately I won't be able to investigate for quite some time. You may have some luck opening it in VLC (which seems to have better compatibility with weird files), or re-encoding the video in ffmpeg directly.
The video can open in VLC, but it seems to be completely muddled. The text from the TextClip does not appear and the frames of the video become only a small, low resolution portion of the actual original video. It seems like the video is put over the text (makes sense) but seems to only take the portion of the frames at the location and size of the text clip, which I presume is very small.
Perhaps this is why it can't play in Window's Movie & TV player: the resolution is simply too small. If this is the case, then there should probably be a warning when compiling the video, saying that if the final video has too small of a resolution, then some video players cannot properly stream it. The resolution might not be the issue, though.
The problem is reproducible on my system with the following specifications:
I also tried an equivalent script for Moviepy version 2.0.0.dev2 (f5944d4), intended to be run from the root directory of the moviepy
repository:
from moviepy.editor import *
first_five_seconds = VideoFileClip("./media/big_buck_bunny_0_30.webm").subclip(0, 5)
first_five_seconds.write_videofile("./clips/first_five_seconds.mp4")
title = TextClip("Title", font_size=75, color="green")
title = title.with_position("bottom").with_duration(4)
with_title_screen = CompositeVideoClip([title, first_five_seconds])
with_title_screen.write_videofile("./clips/with_title_screen.mp4")
This script is slightly more successful. A 5 second video is created with the original sound. But the video is still missing, and VLC spits out a bunch of decode errors (same as with version 1.0.3):
[h264 @ 0x7f9910cb9f80] hardware accelerator failed to decode picture
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).
I was facing similar issue. I concatenated multiple TextClips on top of ImageClips. Sometimes, the videos were playable in QuickTimePlayer, sometimes not. But the clips were always playable in VLC.
In my case, I figured out that the reason was that the final clip had an odd number as the width. On making sure final videos had even dimensions, all the videos became compatible with QuickTimePlayer as well. Stupid bug.
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
Specifications
3.8.3
1.0.3
ImageMagick-7.0.10-Q16-HDRI