2

私のコード:

    clip1 = VideoFileClip(changename).subclip(0,40)
    clip2 = VideoFileClip(changename).subclip(int(duration/2-20), int(duration/2+20) )
    clip3 = VideoFileClip(changename).subclip(duration-41,duration-1)
    final_clip = concatenate_videoclips([clip1,clip2,clip3])

    final_clip.resize(width=480).write_videofile(exportfile, fps=25)

例外トレースバック (最新の呼び出しが最後)

    <ipython-input-6-66d5567477fd> in <module>()
          8     #final_clip.set_audio(audio.set_duration(final_clip))
          9 
    ---> 10     final_clip.resize(width=480).write_videofile(exportfile, fps=25)
         11 
         12     if meta['width']>480:

    /Applications/anaconda/lib/python2.7/site-packages/moviepy/video/fx/resize.pyc in resize(clip, newsize, height, width, apply_to_mask)
        142         fl = lambda pic: resizer(pic.astype('uint8'), newsize)
        143 
    --> 144     newclip = clip.fl_image(fl)
        145 
        146     if apply_to_mask and clip.mask is not None:

    /Applications/anaconda/lib/python2.7/site-packages/moviepy/video/VideoClip.pyc in fl_image(self, image_func, apply_to)
        512         `get_frame(t)` by another frame,  `image_func(get_frame(t))`
        513         """
    --> 514         return self.fl(lambda gf, t: image_func(gf(t)), apply_to)
        515 
        516     # --------------------------------------------------------------

    /Applications/anaconda/lib/python2.7/site-packages/moviepy/Clip.pyc in fl(self, fun, apply_to, keep_duration)
        134 
        135         #mf = copy(self.make_frame)
    --> 136         newclip = self.set_make_frame(lambda t: fun(self.get_frame, t))
        137 
        138         if not keep_duration:

    <decorator-gen-180> in set_make_frame(self, mf)

    /Applications/anaconda/lib/python2.7/site-packages/moviepy/decorators.pyc in outplace(f, clip, *a, **k)
         12     """ Applies f(clip.copy(), *a, **k) and returns clip.copy()"""
         13     newclip = clip.copy()
    ---> 14     f(newclip, *a, **k)
         15     return newclip
         16 

    /Applications/anaconda/lib/python2.7/site-packages/moviepy/video/VideoClip.pyc in set_make_frame(self, mf)
        652         """
        653         self.make_frame = mf
    --> 654         self.size = self.get_frame(0).shape[:2][::-1]
        655 
        656 

    <decorator-gen-137> in get_frame(self, t)

    /Applications/anaconda/lib/python2.7/site-packages/moviepy/decorators.pyc in wrapper(f, *a, **kw)
         87         new_kw = {k: fun(v) if k in varnames else v
         88                  for (k,v) in kw.items()}
    ---> 89         return f(*new_a, **new_kw)
         90     return decorator.decorator(wrapper)
         91 

    /Applications/anaconda/lib/python2.7/site-packages/moviepy/Clip.pyc in get_frame(self, t)
         93                 return frame
         94         else:
    ---> 95             return self.make_frame(t)
         96 
         97     def fl(self, fun, apply_to=[] , keep_duration=True):

    /Applications/anaconda/lib/python2.7/site-packages/moviepy/Clip.pyc in <lambda>(t)
        134 
        135         #mf = copy(self.make_frame)
    --> 136         newclip = self.set_make_frame(lambda t:         fun(self.get_frame, t))
        137 
        138         if not keep_duration:

    /Applications/anaconda/lib/python2.7/site-packages/moviepy/video/VideoClip.pyc in <lambda>(gf, t)
        512         `get_frame(t)` by another frame,  `image_func(get_frame(t))`
        513         """
    --> 514         return self.fl(lambda gf, t: image_func(gf(t)), apply_to)
        515 
        516     # --------------------------------------------------------------

    /Applications/anaconda/lib/python2.7/site-packages/moviepy/video/fx/resize.pyc in <lambda>(pic)
        140 
        141     else:
    --> 142         fl = lambda pic: resizer(pic.astype('uint8'), newsize)
        143 
        144     newclip = clip.fl_image(fl)

    /Applications/anaconda/lib/python2.7/site-packages/moviepy/video/fx/resize.pyc in resizer(pic, newsize)
         30             pilim = Image.fromarray(pic)
         31             resized_pil = pilim.resize(newsize[::-1], Image.ANTIALIAS)
    ---> 32             arr = np.fromstring(resized_pil.tostring(), dtype='uint8')
         33             return arr.reshape(newshape)
         34         resizer.origin = "PIL"

    /Applications/anaconda/lib/python2.7/site-packages/PIL/Image.pyc in tostring(self, *args, **kw)
        684     def tostring(self, *args, **kw):
        685         raise Exception("tostring() has been removed. " +
    --> 686                         "Please call tobytes() instead.")
        687 
        688     def tobitmap(self, name="image"):

    Exception: tostring() has been removed. Please call tobytes() instead.

resize() 関数のヘルプ:

    resize(clip, newsize=None, height=None, width=None, apply_to_mask=True)
     |      Returns a video clip that is a resized version of the clip.
     |      
     |      Parameters
     |      ------------
     |      
     |      newsize:
     |        Can be either 
     |          - ``(height,width)`` in pixels or a float representing
     |          - A scaling factor, like 0.5
     |          - A function of time returning one of these.
     |              
     |      width:
     |        width of the new clip in pixel. The height is then computed so
     |        that the width/height ratio is conserved. 
     |              
     |      height:
     |        height of the new clip in pixel. The width is then computed so
     |        that the width/height ratio is conserved.
     |      
     |      Examples
     |      ----------
     |               
     |      >>> myClip.resize( (460,720) ) # New resolution: (460,720)
     |      >>> myClip.resize(0.6) # width and heigth multiplied by 0.6
     |      >>> myClip.resize(width=800) # height computed automatically.
     |      >>> myClip.resize(lambda t : 1+0.02*t) # slow swelling of the clip

すべての例を試しました: resize( (width,height) ), resize(domsampling), resize(width=800), resize(lambda t : 1+0.02*t). しかし、それらのすべてが同じエラーを取得しています。

4

0 に答える 0