Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.47k stars 1.56k forks source link

ImageSequenceClip error #1523

Open Timtaran opened 3 years ago

Timtaran commented 3 years ago

import os
from moviepy.editor import *
def collect(image_folder, video_name):
    img=[]
    img = [image_folder+img for img in os.listdir(image_folder) if img.endswith(".png")]
    print(img, os.listdir(image_folder))
    clips = ImageSequenceClip(img, fps=60)
    new_clip = concatenate_videoclips([clips, clips, clips, clips, clips])
    #clips.write_videofile(video_name)
    new_clip.write_videofile('/root/mp'+video_name)
def add_audio(video_name, music_name):
    videoclip = VideoFileClip(video_name)
    audioclip = AudioFileClip(music_name)

    new_audioclip = CompositeAudioClip([audioclip])
    videoclip.audio = new_audioclip
    videoclip.write_videofile(f"{video_name.replace('.mp4', '')}_new.mp4")
-->

#### Expected Behavior

#### Actual Behavior
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/PIL/ImageFile.py", line 247, in load
    s = read(self.decodermaxblock)
  File "/usr/local/lib/python3.8/dist-packages/PIL/PngImagePlugin.py", line 896, in load_read
    cid, pos, length = self.png.read()
  File "/usr/local/lib/python3.8/dist-packages/PIL/PngImagePlugin.py", line 162, in read
    length = i32(s)
  File "/usr/local/lib/python3.8/dist-packages/PIL/_binary.py", line 75, in i32be
    return unpack_from(">I", c, o)[0]
struct.error: unpack_from requires a buffer of at least 4 bytes for unpacking 4 bytes at offset 0 (actual buffer size is 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/imageio/plugins/pillow.py", line 669, in pil_try_read
    im.getdata()[0]
  File "/usr/local/lib/python3.8/dist-packages/PIL/Image.py", line 1282, in getdata
    self.load()
  File "/usr/local/lib/python3.8/dist-packages/PIL/ImageFile.py", line 253, in load
    raise OSError("image file is truncated") from e
OSError: image file is truncated

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 4, in <module>
    collect('/root/mp'+folder, 'result.mp4')
  File "/root/mp/models.py", line 7, in collect
    clips = ImageSequenceClip(img, fps=60)
  File "/usr/local/lib/python3.8/dist-packages/moviepy/video/io/ImageSequenceClip.py", line 89, in __init__
    image1=imread(image)
  File "/usr/local/lib/python3.8/dist-packages/imageio/core/functions.py", line 265, in imread
    reader = read(uri, format, "i", **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/imageio/core/functions.py", line 186, in get_reader
    return format.get_reader(request)
  File "/usr/local/lib/python3.8/dist-packages/imageio/core/format.py", line 170, in get_reader
    return self.Reader(self, request)
  File "/usr/local/lib/python3.8/dist-packages/imageio/core/format.py", line 221, in __init__
    self._open(**self.request.kwargs.copy())
  File "/usr/local/lib/python3.8/dist-packages/imageio/plugins/pillow.py", line 298, in _open
    return PillowFormat.Reader._open(self, pilmode=pilmode, as_gray=as_gray)
  File "/usr/local/lib/python3.8/dist-packages/imageio/plugins/pillow.py", line 135, in _open
    pil_try_read(self._im)
  File "/usr/local/lib/python3.8/dist-packages/imageio/plugins/pillow.py", line 680, in pil_try_read
    raise ValueError(error_message)
ValueError: Could not load "" 
Reason: "image file is truncated"
Please see documentation at: http://pillow.readthedocs.io/en/latest/installation.html#external-libraries

#### Steps to Reproduce the Problem
<!-- Please include code that demonstrates this problem so that we can reproduce it. For advice on how to do this, see https://stackoverflow.com/help/mcve -->

#### Specifications

  - Python Version: 3.8.5
  - Moviepy Version: 1.0.3
  - Platform Name: Ubuntu (server)
  - Platform Version: 20.04
Timtaran commented 3 years ago

img-https://pastebin.com/ems93hi2

Timtaran commented 3 years ago

if I'm rendering video not in 4k, I hasn't got error