r/moviepy • • 22d ago

compute_position error when passing "with_position(width,height)" to TextClip

1 Upvotes

Working on something to visualize pronunciation of written indigenous languages. Not a python expert ..

Syllables in a word presented as individual textclips. A word is presented as a series of textclips. As recorded word audio is spoken, each syllable textclip changes its appearance corresponding to when it is spoken.

I need to graphically position the clips (left to right for the language I work with)

I'm trying to create a list of TextClip objects from a class inheriting TextClip in a loop.
I can pass text, start and end duration variables without issue. But when I pass with_position parameters in my loop I get a compute_position error:

tools.py", line 289, in compute_position pos = list(pos)
"TypeError: 'int' object is not iterable

I use the [-1] tool to identify eachTextGrid item as they are created and get its width.
I use this width to set the x position of the next TextGrid item.

BUT doing this creates an error.
I confirmed that data passed are integers,

I can setup the position values within the nested array, that I use to hold to test values without generating an error

but the long term goal is to be able to pass both the text, the syllables and their timing as a praat textgrid file, and use MoviePy to figure out and set their positioning.

And pass a spoken word audio file that has had its syllable pronunciation timing documented with Praat. https://www.fon.hum.uva.nl/praat/, https://pypi.org/project/praatio/

My goal is a MoviePy script that generates video illustration of a words pronunciation as the word is spoken, by passing the audio file and an appropriate textgrid file.

Many/most indigenous languages use sounds (phonemes) not used in western languages and represent them with different sets of lettering, graphemes or syllabics, depending on the language. MoviePy could offer a way of illustrating this by changing the visual parameters of a TextClip, or overlaying differently configured TextClips as a word is spoken.

My testing code is:

font_size = 42

class Syltext(TextClip): # a class for the syllable presentation

def __init__(self,*args, **kwargs):

super().__init__(

font_size = font_size,

color="black",

stroke_color="black",

bg_color="white",

stroke_width=2,

*args, **kwargs

)

mtrix = [ #array to hold syllable data (will be replaced with passing Praat textgrid data)

[.5,2,"Must'"],#start time, duration, text

[2,2,"i'"],

[4,1.5,"muhw"]

]

#Must'i'muhw - People

cliplist = [] # a list to hold all the clips
sylw = 0 #width position of syllables, start at zero, increment by width of syllables
totw = 0 #variable for total width, taken from last syllable width

for i in range (3):

#put syllable clips in a list of Syltext objects

cliplist.append(Syltext(text=(mtrix[i][2])).with_start(mtrix[i][0]).with_duration(mtrix[i][1]).with_position(sylw,100))

sylw = cliplist[-1].w # get width of last syllable created

if i == 2:
totw = cliplist[-1].w # get the total width of the entire word.

bgclip = ColorClip(size =(totw,100),color = white ,duration = 6) # a background clip with size, color and duration

cliplist.insert(0,bgclip) # add the color clip to 1st in clip list

audioclip = AudioFileClip("audio.wav")

video = CompositeVideoClip(cliplist)

video.preview()

final = video.with_audio(audioclip)

final.write_videofile("videofile.mp4",fps=12,audio_codec="aac")


r/moviepy • • Oct 04 '26

Is this project still maintained?

2 Upvotes

It has been about a year since last release. Though the longest gap is about 4 years, I still wonder if this project is still maintained. If yes, when will the next release come?


r/moviepy • • Jun 20 '26

speed drastically reduced after I updated the moviepy version, and it was slow to begin with.

1 Upvotes

I have a script I've used for a few years, where it takes a ton of cell phone quality videos, like instagram clips and whatnot, and it puts them all together in 1 video so there are 3 playing side by side, and it concatenates them all together. Previously I could make a 30 minute video and it would take usually about 4 hours, give or take, which already seamed pretty exorbitant, but I dealt with it. Well I recently remade my whole python installation, which required reinstalling the latest version on moviepy, and I changed around a handful of functions that got their names changed, like crop to cropped and rotate to rotated, and now a 30 minute video is estimated to take 24 hours. Is moviepy just unusable now?


r/moviepy • • Mar 13 '26

ERRO: 'VideoFileClip' object has no attribute 'fl'

1 Upvotes

How to solve this ? What is the function I can use in the place of fl


r/moviepy • • Mar 13 '26

Keyframable opacity

1 Upvotes

How to make opacity goes from a value to another in a certain time ? For example: From 0.45 in 1s to 0.8 in 2s to 1 in 3s and so on.


r/moviepy • • Mar 01 '26

Issue with CompositeVideoClip

1 Upvotes

I am trying to run a simple moviepy (version 2.2.1) example where I'm cutting a video into clips to edit the clips individually, but running into issues by simply cutting into clips and rejoining them:

import moviepy as mp

clip = mp.VideoFileClip('test4.mp4')

fps = clip.fps

c0 = 2

c1 = 4

clip1 = clip.subclipped(0, c0)

clip2 = clip.subclipped(c0, c1)

clip3 = clip.subclipped(c1, clip.end)

clip = mp.CompositeVideoClip([clip1, clip2, clip3])

clip1.close()

clip2.close()

clip3.close()

clip.write_videofile('test_out.mp4', threads=8)

clip.close()

The result is a long traceback, starting and ending with:

Traceback (most recent call last):

File "test.py", line 24, in <module>

clip.write_videofile('test_out.mp4', threads=8)

...

File ".../site-packages/moviepy/audio/io/readers.py", line 155, in read_chunk

s = self.proc.stdout.read(self.nchannels * chunksize * self.nbytes)

^^^^^^^^^^^^^^^^

AttributeError: 'NoneType' object has no attribute 'stdout'

Does anyone have any ideas what could be causing this? Thanks in advance!


r/moviepy • • Feb 08 '26

Fast MoviePy with pro TextEffects

4 Upvotes

I have boosted MoviePy 2.2.1 performance 10x and added awesome text effects (typically used for subtitles). https://github.com/HolyFot/moviepy-fast


r/moviepy • • Jan 16 '26

Any way to make it not break words in parts?

1 Upvotes

r/moviepy • • Nov 27 '25

'AudioFileClip' object has no attribute 'volumex'

Post image
1 Upvotes

Someone can help me please ?


r/moviepy • • Nov 09 '25

I made a Scene Description Language that uses MoviePy to create videos. SceneWeaver

6 Upvotes

I wanted to make reproducible videos for one of my apps so I can easily update the video when the app changes. So I made a "template language" for MoviePy.

https://github.com/barebaric/sceneweaver

It also has some more advanced features like composition or scene caching.

Example Usage:

Starting

First, create a new specification file to define your video's structure.

sceneweaver create my_video.yaml    # creates a new template you can edit
sceneweaver generate my_video.yaml

Example specification

Here is a basic example of a my_video.yaml file:

settings:
  width: 1920
  height: 1080
  fps: 30
  output_file: output.mp4

scenes:
  - id: intro_card
    type: title_card
    duration: 3  # optional if audio is given
    audio: my/narration.wav
    title: Hello, SceneWeaver!
    transition:
      type: cross-fade
      duration: 1

  - id: main_image
    type: image
    duration: 10
    image: ~/path/to/your/image.png
    stretch: false # Preserves aspect ratio
    width: 80  # As 80% of the screen width
    annotations:
      - type: text
        location: bottom
        content: This is a caption for the image.
    cache:
      max-size: 2GB
    transition:
      type: cross-fade
      duration: 2

  - id: outro
    type: video
    fps: 25
    file: something.mp4
    effects:
      - type: fade-out
        duration: 1

But way more is supported, including recording audio, applying effects, etc. The commands are explained in the README on Github.

I imagine it is easy to add scenes for AI generated clips as well, but did not do that yet.


r/moviepy • • Nov 09 '25

I created a performance-focused alternative to MoviePy

13 Upvotes

Hey everyone,

MoviePy is an incredibly powerful tool. However, for some of my projects, I kept running into performance bottlenecks, especially with compositions involving multiple layers, text overlays, and transformations.

So, I decided to build a solution for my own needs and wanted to share it with this community first to see if it might be useful to others. It's a performance-focused alternative called MovieLite.

The core idea was to keep a simple, chainable API similar to MoviePy, but to aggressively optimize the rendering pipeline using Numba (JIT compilation) for CPU-based tasks. The result has been pretty promising. These are my benchmark results for some examples (you can find them in my repo):

TaskmovielitemoviepySpeedup
No processing6.92s6.92s1.00x
Video zoom (1.0x → 1.5x)9.91s31.44s3.17x
Fade in/out7.63s8.44s1.11x
Text overlay8.98s33.70s3.75x
Video overlay18.94s72.44s3.83x
Alpha video overlay12.01s40.31s3.36x
Complex mix*39.66s166.88s4.21x
Overall104.04s360.12s3.46x

*Complex mix includes: video with zoom + fade, image clips with fade, text overlay, video overlay - all composed together.

Now, to be clear, this is not a full replacement for MoviePy. My focus was on making the common tasks significantly faster.

I'm still early in the journey, but it's reached a point where it's useful for my own projects. I'd genuinely love to get some feedback from MoviePy users like you.

  • Is this something that could be useful in your workflows?

  • Are there any obvious pain points or missing features that feel essential?

Any thoughts or critiques are welcome!

Thanks for taking a look! :)


r/moviepy • • Sep 21 '25

Batching video rendering

2 Upvotes

I have started using moviepy quite recently and found it to be a real pain as all LLM's refer to the version 1 syntax and I'm working with the latest 2 version. But kept going nevertheless as I could see moviepy as a major time saver.

However, now that my script is almost done, I'm hitting the very real bottleneck of painfully slow video rendering.

I am currently looking at ways to make the whole thing faster by way of multiprocessing, meaning to divide the video in batches and then stitch everything together with ffmpeg.

Is there anything alike already implemented anywhere? Does this even make sense?


r/moviepy • • Sep 14 '25

Progress Bar

Post image
4 Upvotes

Hi guys, I implemented a video length progress tracker for my own project. Thought to share you here.

Code:

import numpy as np, colorsys
from moviepy import (
    ImageClip,
)
RESOLUTIONS = (1080, 1920)  # Resolution for the final video
# Imports


def progress_bar(
    barHeight: str = 20,
    color="white",
    duration: int = 30,
) -> ImageClip:
    """
    Create a progress bar for the video.

    Args:
        barHeight (int): Height of the progress bar.
        color (str): Color of the progress bar. Can be "rainbow", "white", "black", or a tuple of two hex colors.
        duration (int): Duration of the video.
    """

    def make_bar(w, h):
        arr = np.zeros((h, w, 3), dtype=np.uint8)
        if color == "rainbow":
            for x in range(w):
                r, g, b = colorsys.hsv_to_rgb(x / w, 1.0, 1.0)
                arr[:, x] = [int(255 * r), int(255 * g), int(255 * b)]
        elif color == "white":
            arr[:] = [255, 255, 255]
        elif color == "black":
            arr[:] = [0, 0, 0]
        elif isinstance(color, tuple) and len(color) == 2:
            # Gradient between two hex colors
            def hex_to_rgb(hex_color):
                hex_color = hex_color.lstrip("#")
                return np.array([int(hex_color[i : i + 2], 16) for i in (0, 2, 4)])

            start = hex_to_rgb(color[0])
            end = hex_to_rgb(color[1])
            for x in range(w):
                arr[:, x] = (start + (end - start) * (x / (w - 1))).astype(np.uint8)
        else:
            arr[:] = [255, 255, 255]
        return arr

    bar_img = make_bar(RESOLUTIONS[0], barHeight)
    bar_clip = ImageClip(bar_img, duration=duration).with_position(
        (0, RESOLUTIONS[1] - barHeight)
    )

    def crop_progress(get_frame, t):
        frame = get_frame(t)
        prog = int(RESOLUTIONS[0] * (t / duration))
        return frame[:, :prog]

    return bar_clip.transform(crop_progress, apply_to=["mask", "video"])

Usage:

img_clip = progress_bar(duration=full_duration, color=("#fcbd34", "#ff9a00"))

img_clip = progress_bar(duration=full_duration, color="rainbow")
img_clip = progress_bar(duration=full_duration, color="white")

r/moviepy • • Aug 27 '25

TextClip - font 🥴

2 Upvotes

Not able to get TextClip working. If I pass in font "Arial", I get error "TypeError: multiple values for argument 'font'" and if I don't pass in or pass in None, then I get error "ValueError: Invalid font <unk>, pillow failed to use it with error cannot open resource".

Here is my code snippet:

caption_style = {'font': 'Arial-Bold', 'font_size': 40, 'color': 'white'} txt = (TextClip(word, **caption_style) .set_position(("center", "bottom")) .set_start(start) .set_end(end))

I have tried changing it to direct parameters. Do I need .ttf appended in the font name? Or tell me what's wrong 🤔


r/moviepy • • Jul 16 '25

PicTex, an alternative to TextClip for text with shadows, gradients, and outlines

5 Upvotes

Hey everyone,

Like many of you, I've always found TextClip to be a bit limited, especially when it comes to styling. Since v2.x, it's powered by Pillow, which makes advanced effects like proper shadows, gradients, or text outlines really difficult to implement.

I've been working on a side project to solve this problem and wanted to share it with this community, as I think it could be a really useful companion to MoviePy.

It's called PicTex, a Python library specifically designed to create beautifully styled text images with a simple, fluent API.

How it works with MoviePy: The idea is simple: you use pictex to generate a PNG image of your text with a transparent background, and then use that PNG as an ImageClip in MoviePy. This gives you full control over the styling.

Here's a quick example (using moviepy v2.x):

from pictex import Canvas, LinearGradient
from moviepy import *

# 1. Create your styled text with PicTex
canvas = (
    Canvas()
    .font_family("Poppins-Bold.ttf")
    .font_size(60)
    .color(LinearGradient(["blue", "cyan"]))
    .add_shadow(offset=(2, 2), blur_radius=1, color="black")
)
text_image = canvas.render("Your text")

# 2. Use the generated image in MoviePy
text_clip = (
    ImageClip(text_image.to_numpy(True))
    .with_duration(3)
    .with_position(("center", "center"))
)

text_clip.with_fps(10).write_videofile("output.mp4")

Here's what you can do with it that's hard with TextClip:

  • Shadows: Add multiple, soft drop shadows to your text.

  • Gradients: Use linear gradients for text fills or backgrounds.

  • Outlines (Strokes): Easily add a contour around your text.

  • Advanced Typography: Use any custom .ttf font, control font weight precisely, and get high-quality anti-aliasing.

  • Emojis & Fallbacks: It automatically handles emojis and special characters seamlessly.

The project is open-source and available on PyPI (pip install pictex).

GitHub Repo: https://github.com/francozanardi/pictex

It's a little slower than Pillow, but it's good enough (around 5 MS per image in my laptop, depending on the size and used effects).

I hope this is useful for some of you! I'd love to hear your feedback or if you have any ideas on how it could integrate even better with a video workflow.


r/moviepy • • Jun 08 '25

EFFECTS

1 Upvotes

HELLO, A QUESTION DOES ANYONE KNOW HOW THE EFFECTS ARE CREATED TO EDIT A VIDEO FOR MOVIEPY WITH CUSTOM EFFECTS


r/moviepy • • May 31 '25

Where do I get the documentation for moviepy 1.0.3 (or older)?

4 Upvotes

Hi. I am a software engineer who is currently helping to maintain some old software that uses Moviepy 1.0.3, so I need help finding documentation for Moviepy 1.0.3.


r/moviepy • • May 31 '25

NameError: name 'moviepy' is not defined even tho have moviepy in my pip list

Post image
1 Upvotes

What the title said...


r/moviepy • • May 16 '25

Make images bigger than the screen?

1 Upvotes

Seems like images are automatically stretched to fit the screen. This is nice but what if I want to have the image larger than the screen? I tried various "resize" methods but none of them seem to work.

Why? I want to create zoom out and panning effects. As of now, the effects work, but black bars appear as it zooms out or pan a certain direction (vfx.Scroll)


r/moviepy • • May 14 '25

Expected Date of new release?

1 Upvotes

I am interested in the timeplan for a new release. In my setup I depend on pillow > 11. This was only enabled after the last release.


r/moviepy • • May 07 '25

How to create a video mask?

2 Upvotes

So I am trying to use a video mask (a video with just black and white). It doesn't really work (code below).

Here's a frame from the output:

The red arrows are pointing at black. The mask video is black paint running down a white background. So it is outlining the black parts of the mask for some reason. It seems like the mask is able to detect the black transparency, but no matter what video clip I use (I have verified that the video clips' whites are indeed 255, 255, 255 pure white) it makes the white transparent and only shows the non-black/non-white edges of the mask. The dice picture is the background image clip and what is outline is the top image clip.

I have narrowed the problem down to the code. It has nothing to do with the video itself (I have tried many black and white videos from several sources and file formats and encoding settings etc.). Also, it's worth noting that I tried this code with a static black and white image mask and it worked as intended (white opaque, black transparent vs. how it's working now-- everything transparent except for non-white/ non-black).

Therefore, my conclusion is that there must be some other process to create a video mask that's different from creating a static image mask. But maybe I'm wrong, idk. I am very new to MoviePy.

CODE:

from moviepy import VideoFileClip
from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip
from moviepy.video.VideoClip import ImageClip

# Load the video clip
mask_input_path = ".\\source\\simple_mask_video.mp4"
output_path = ".\\output\\output_video.mp4" 

mask_clip = VideoFileClip(mask_input_path, is_mask=True)
main_duration = mask_clip.duration

over_image_with_mask = ImageClip(img=".\\source\\top_image.png", duration=main_duration).with_mask(mask_clip)

under_image = ImageClip(".\\source\\bottom_image.png", duration=main_duration)

# Composite the bottom_clip and top_clip on top of the blank_clip
composited_clip = CompositeVideoClip(size=(1080,1920), clips=[
    under_image,
    over_image_with_mask,
    ]
    , bg_color=(0, 0, 0))


# Write the result to a file
composited_clip.write_videofile(output_path, codec="libx264", audio_codec="aac", fps=30)

# Close the clips
mask_clip.close()

r/moviepy • • May 01 '25

MoviePY blur

1 Upvotes

Hello! How could I create this inpaint effect in the subtitle part of this video examples using MoviePY or antoher video library? Example: https://www.instagram.com/reel/DIfp400lekG/?igsh=eHN6YW5nM2tpa G5v


r/moviepy • • Apr 15 '25

Where is the [docs] folder?

1 Upvotes

On Windows 11.
Ran the pip install command as detailed here. It says go to the docs folder and run make html. Where is the docs folder?
The online documentation (here) is automatically built at every push to the master branch. To build the documentation locally, install the extra dependencies via pip install moviepy[doc], then go to the docs folder and run make html.


r/moviepy • • Apr 10 '25

Vedio

0 Upvotes

from moviepy.editor import * from moviepy.video.tools.subtitles import SubtitlesClip from moviepy.video.fx.all import fadein, fadeout

إعداد النصوص لكل جزء في الفيديو

scenes = [ ("هل تصدق بالأشباح؟", 0, 3), ("هذه قصة عمر... الرجل الذي عاش في بيت مسكون.", 3, 6), ("في أول ليلة... سمع عمر أصوات غريبة من الطابق العلوي.", 6, 10), ("في اليوم التالي، بدأت الأشياء تتحرك من مكانها!", 10, 14), ("وفي الليلة الثالثة... رآها.", 14, 17), ("امرأة تقف في نهاية الممر... فقط تنظر.", 17, 21), ("بحث عمر عن تاريخ المنزل، ووجد الصدمة!", 21, 25), ("المرأة كانت تسكن هنا... وماتت في ظروف غامضة.", 25, 29), ("في إحدى الليالي، وجد رسالة مخبأة خلف الحائط:", 29, 33), (""لن تخرج أبدًا."", 33, 36), ("(يُغلق الباب بقوة)", 36, 39), ("النهاية... أو ربما... البداية؟", 39, 43) ]

تحميل صور الخلفية من ملفات محلية أو استخدام لون ثابت

clips = [] for i, (text, start, end) in enumerate(scenes): duration = end - start txt_clip = TextClip(text, fontsize=50, font="Arial-Bold", color="white", bg_color="black", size=(720, 1280), method="caption") txt_clip = txt_clip.set_duration(duration).set_position("center") txt_clip = fadein(txt_clip, 0.5).fx(fadeout, 0.5) clips.append(txt_clip)

تجميع المقاطع

final_video = concatenate_videoclips(clips, method="compose")

إضافة موسيقى رعب خلفية

audio = AudioFileClip("/mnt/data/horror_music.mp3").subclip(0, final_video.duration) final_video = final_video.set_audio(audio)

تصدير الفيديو

output_path = "/mnt/data/omar_haunted_house_story.mp4" final_video.write_videofile(output_path, fps=24)