[Python] Moviepy - Output video not playable

Discussão em 'Python' iniciado por Stack, Julho 13, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using the library moviepy on Linux Mint 18.1.

    Specifically, it's moviepy 0.2.3.2 on python 3.5.2

    Since I'm getting started, I tried this simple script, which should concatenate two videos one after the other:

    import moviepy.editor as mp

    video1 = mp.VideoFileClip("short.mp4")
    video2 = mp.VideoFileClip("motivation.mp4")

    final_video = mp.concatenate_videoclips([video1,video2])
    final_video.write_videofile("composition.mp4")


    The two videos are short random videos that I downloaded from YouTube. They both play perfectly, both with VLC and the standard video player provided with Linux Mint.

    The script runs fine with no errors, with the final message:

    [MoviePy] >>>> Building video composition.mp4
    [MoviePy] Writing audio in compositionTEMP_MPY_wvf_snd.mp3
    100%|██████████████████████████████| 1449/1449 [00:23<00:00, 59.19it/s]
    [MoviePy] Done.
    [MoviePy] Writing video composition.mp4
    100%|██████████████████████████████| 1971/1971 [11:34<00:00, 2.84it/s]
    [MoviePy] Done.
    [MoviePy] >>>> Video ready: composition.mp4


    The file is indeed created, and it also have a size (about 20 MB). However, when I try to play it, nothing happens: it seems to be corrupted. The standard video player even tells me that "there is no video stream to be played".

    If I try to do the same with the interactive console, and use final_video.preview(), I get an AttributeError, along with this traceback:

    In [5]: final_video.preview()
    Exception in thread Thread-417:
    Traceback (most recent call last):
    File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
    File "/usr/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
    File "<decorator-gen-211>", line 2, in preview
    File "/usr/local/lib/python3.5/dist-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
    File "/usr/local/lib/python3.5/dist-packages/moviepy/audio/io/preview.py", line 49, in preview
    sndarray = clip.to_soundarray(tt,nbytes=nbytes, quantize=True)
    File "<decorator-gen-184>", line 2, in to_soundarray
    File "/usr/local/lib/python3.5/dist-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
    File "/usr/local/lib/python3.5/dist-packages/moviepy/audio/AudioClip.py", line 107, in to_soundarray
    fps = self.fps
    AttributeError: 'CompositeAudioClip' object has no attribute 'fps'


    and the video seems frozen at the first frame.

    I don't have any clue, since everything seems to work fine (except with the preview, which doesn't work because of the error). I tried to reinstall ffmpeg, but no succes: everything is exactly the same. Without any useful error, how can I fix this problem?

    Continue reading...

Compartilhe esta Página