當前位置: 首頁>>代碼示例>>Python>>正文


Python Clip.Clip類代碼示例

本文整理匯總了Python中moviepy.Clip.Clip的典型用法代碼示例。如果您正苦於以下問題:Python Clip類的具體用法?Python Clip怎麽用?Python Clip使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Clip類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

    def __init__(self, clips):

        Clip.__init__(self)
        self.clips = clips
        
        ends = [c.end for c in self.clips]
        self.nchannels = max([c.nchannels for c in self.clips])
        if not any([(e is None) for e in ends]):
            self.duration = max(ends)
            self.end = max(ends)

        def make_frame(t):
            
            played_parts = [c.is_playing(t) for c in self.clips]
            
            sounds= [c.get_frame(t - c.start)*np.array([part]).T
                     for c,part in zip(self.clips, played_parts)
                     if (part is not False) ]
                     
            if isinstance(t,np.ndarray):
                zero = np.zeros((len(t),self.nchannels))
                
            else:
                zero = np.zeros(self.nchannels)
                
            return zero + sum(sounds)

        self.make_frame = make_frame
開發者ID:bobatsar,項目名稱:moviepy,代碼行數:28,代碼來源:AudioClip.py

示例2: __init__

 def __init__(self, ismask=False):
     Clip.__init__(self)
     self.mask = None
     self.audio = None
     self.pos = lambda t: (0, 0)
     self.relative_pos = False
     self.ismask = ismask
開發者ID:thgil,項目名稱:moviepy,代碼行數:7,代碼來源:VideoClip.py

示例3: __init__

 def __init__(self, get_frame = None):
     Clip.__init__(self)
     if get_frame:
         self.get_frame = get_frame
         frame0 = self.get_frame(0)
         if hasattr(frame0, '__iter__'):
             self.nchannels = len(list(frame0))
         else:
             self.nchannels = 1
開發者ID:Rentish,項目名稱:moviepy,代碼行數:9,代碼來源:AudioClip.py

示例4: __init__

    def __init__(self, filename, buffersize=200000, nbytes=2, fps=44100):
        

        Clip.__init__(self)
            
        self.filename = filename
        self.reader = FFMPEG_AudioReader(filename,fps=fps,nbytes=nbytes,
                                         bufsize=buffersize+100)
        self.fps = fps
        self.duration = self.reader.duration
        self.end = self.duration
        
        self.nframes = self.reader.nframes
        self.buffersize= buffersize
        self.buffer= None
        self._fstart_buffer = 1
        self._buffer_around(1)
        
        def gf(t):
            bufsize = self.buffersize
            if isinstance(t,np.ndarray):
                # lazy implementation, but should not cause problems in
                # 99.99 %  of the cases
                result = np.zeros((len(t),2))
                in_time = (t>=0) & (t < self.duration)
                inds = (self.fps*t+1).astype(int)[in_time]
                f_tmin, f_tmax = inds.min(), inds.max()
                
                if not (0 <= (f_tmin - self._fstart_buffer) < len(self.buffer)):
                    self._buffer_around(f_tmin)
                elif not (0 <= (f_tmax - self._fstart_buffer) < len(self.buffer)):
                    self._buffer_around(f_tmax)
                    
                try:
                    tup = in_time.nonzero()
                    inds2 = inds - self._fstart_buffer
                    result[in_time] = self.buffer[inds - self._fstart_buffer]
                    return result
                except IndexError as error:
                    print ("Error: wrong indices in video buffer. Maybe"+
                           " buffer too small.")
                    raise error
                    
            else:
                ind = int(self.fps*t)
                if ind<0 or ind> self.nframes: # out of time: return 0
                    return np.zeros(self.nchannels)
                    
                if not (0 <= (ind - self._fstart_buffer) <len(self.buffer)):
                    # out of the buffer: recenter the buffer
                    self._buffer_around(ind)
                    
                # read the frame in the buffer
                return self.buffer[ind - self._fstart_buffer]

        self.get_frame = gf
開發者ID:ZCT,項目名稱:moviepy,代碼行數:56,代碼來源:AudioFileClip.py

示例5: __init__

    def __init__(self, clips):

        Clip.__init__(self)
        self.clips = clips
        
        ends = [c.end for c in self.clips]
        if not any([(e is None) for e in ends]):
            self.duration = max(ends)

        def gf(t):
            sounds= [c.get_frame(t - c.start)
                     for c in clips if c.is_playing(t)]
            if isinstance(t,np.ndarray):
                zero = np.zeros((len(t),2))
            else:
                zero = np.zeros(2)
            return zero + sum(sounds)

        self.get_frame = gf
開發者ID:ShaguptaS,項目名稱:moviepy,代碼行數:19,代碼來源:AudioClip.py

示例6: set_get_frame

 def set_get_frame(self, gf):
     newclip = Clip.set_get_frame(self, gf)
     newclip.size = newclip.get_frame(0).shape[:2][::-1]
     return newclip
開發者ID:thgil,項目名稱:moviepy,代碼行數:4,代碼來源:VideoClip.py


注:本文中的moviepy.Clip.Clip類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。