• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python Clip.Clip类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python config.get_setting函数代码示例发布时间:2022-05-27
下一篇:
Python movie.Movie类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap