当前位置: 首页>>代码示例>>Python>>正文


Python editor.VideoClip方法代码示例

本文整理汇总了Python中moviepy.editor.VideoClip方法的典型用法代码示例。如果您正苦于以下问题:Python editor.VideoClip方法的具体用法?Python editor.VideoClip怎么用?Python editor.VideoClip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在moviepy.editor的用法示例。


在下文中一共展示了editor.VideoClip方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_gif

# 需要导入模块: from moviepy import editor [as 别名]
# 或者: from moviepy.editor import VideoClip [as 别名]
def make_gif(images, fname, duration=2, true_image=False):
    import moviepy.editor as mpy

    def make_frame(t):
        try:
            x = images[int(len(images)/duration*t)]
        except:
            x = images[-1]

        if true_image:
            return x.astype(np.uint8)
        else:
            return ((x+1)/2*255).astype(np.uint8)

    clip = mpy.VideoClip(make_frame, duration=duration)
    clip.write_gif(fname, fps=len(images) / duration) 
开发者ID:djsutherland,项目名称:opt-mmd,代码行数:18,代码来源:utils.py

示例2: make_gif

# 需要导入模块: from moviepy import editor [as 别名]
# 或者: from moviepy.editor import VideoClip [as 别名]
def make_gif(images, fname, duration=2, true_image=False):
    import moviepy.editor as mpy

    def make_frame(t):
        try:
            x = images[int(len(images)/duration*t)]
        except:
            x = images[-1]

    if true_image:
        return x.astype(np.uint8)
    else:
        return ((x+1)/2*255).astype(np.uint8)

    clip = mpy.VideoClip(make_frame, duration=duration)
    clip.write_gif(fname, fps = len(images) / duration) 
开发者ID:mkocaoglu,项目名称:CausalGAN,代码行数:18,代码来源:utils.py

示例3: make_gif

# 需要导入模块: from moviepy import editor [as 别名]
# 或者: from moviepy.editor import VideoClip [as 别名]
def make_gif(images, fname, duration=2, true_image=False):
  import moviepy.editor as mpy

  def make_frame(t):
    try:
      x = images[int(len(images)/duration*t)]
    except:
      x = images[-1]

    if true_image:
      return x.astype(np.uint8)
    else:
      return ((x+1)/2*255).astype(np.uint8)

  clip = mpy.VideoClip(make_frame, duration=duration)
  clip.write_gif(fname, fps = len(images) / duration) 
开发者ID:AshishBora,项目名称:csgm,代码行数:18,代码来源:dcgan_utils.py

示例4: make_gif

# 需要导入模块: from moviepy import editor [as 别名]
# 或者: from moviepy.editor import VideoClip [as 别名]
def make_gif(images, fname, duration=2, true_image=False):
    import moviepy.editor as mpy

    def make_frame(t):
        try:
            x = images[int(len(images) / duration * t)]
        except:
            x = images[-1]

        if true_image:
            return x.astype(np.uint8)
        else:
            return ((x + 1) / 2 * 255).astype(np.uint8)

    clip = mpy.VideoClip(make_frame, duration=duration)
    clip.write_gif(fname, fps=len(images) / duration) 
开发者ID:YingZhangDUT,项目名称:Cross-Modal-Projection-Learning,代码行数:18,代码来源:utils.py

示例5: make_gif

# 需要导入模块: from moviepy import editor [as 别名]
# 或者: from moviepy.editor import VideoClip [as 别名]
def make_gif(images, fname, duration=2, true_image=False):
	import moviepy.editor as mpy

	def make_frame(t):
		try:
			x = images[int(len(images)/duration*t)]
		except:
			x = images[-1]

		if true_image:
			return x.astype(np.uint8)
		else:
			return ((x+1)/2*255).astype(np.uint8)

	clip = mpy.VideoClip(make_frame, duration=duration)
	clip.write_gif(fname, fps = len(images) / duration) 
开发者ID:changwoolee,项目名称:WGAN-GP-tensorflow,代码行数:18,代码来源:utils.py

示例6: make_movie

# 需要导入模块: from moviepy import editor [as 别名]
# 或者: from moviepy.editor import VideoClip [as 别名]
def make_movie(net, force_function, duration_seconds, output_filename):
    w, h = 300, 100
    scale = 300 / 6

    cart = gz.rectangle(scale * 0.5, scale * 0.25, xy=(150, 80), stroke_width=1, fill=(0, 1, 0))
    pole = gz.rectangle(scale * 0.1, scale * 1.0, xy=(150, 55), stroke_width=1, fill=(1, 1, 0))

    sim = CartPole()

    def make_frame(t):
        inputs = sim.get_scaled_state()
        if hasattr(net, 'activate'):
            action = net.activate(inputs)
        else:
            action = net.advance(inputs, sim.time_step, sim.time_step)

        sim.step(force_function(action))

        surface = gz.Surface(w, h, bg_color=(1, 1, 1))

        # Convert position to display units
        visX = scale * sim.x

        # Draw cart.
        group = gz.Group((cart,)).translate((visX, 0))
        group.draw(surface)

        # Draw pole.
        group = gz.Group((pole,)).translate((visX, 0)).rotate(sim.theta, center=(150 + visX, 80))
        group.draw(surface)

        return surface.get_npimage()

    clip = mpy.VideoClip(make_frame, duration=duration_seconds)
    clip.write_videofile(output_filename, codec="mpeg4", fps=50) 
开发者ID:CodeReclaimers,项目名称:neat-python,代码行数:37,代码来源:movie.py

示例7: make_gif

# 需要导入模块: from moviepy import editor [as 别名]
# 或者: from moviepy.editor import VideoClip [as 别名]
def make_gif(self, gif_path=None):
        """
        :param gif_path: 保存路径
        :return:
        """
        gif_path = gif_path or "deal.gif"
        animation = mpy.VideoClip(self.drawing, duration=self.duration)
        animation.write_gif(gif_path, fps=self.duration) 
开发者ID:tomoncle,项目名称:face-detection-induction-course,代码行数:10,代码来源:input_static_pic_to_gif2_for_class.py

示例8: ipython_display

# 需要导入模块: from moviepy import editor [as 别名]
# 或者: from moviepy.editor import VideoClip [as 别名]
def ipython_display(self, *args, **kwargs):
        """
        Fixes inheritance naming issue with moviepy's ipython_display
        """
        seg_copy = self.copy()
        # Class should also always be set to VideoClip for expected video display
        seg_copy.__class__ = VideoClip().__class__
        return seg_copy.ipython_display(*args, **kwargs) 
开发者ID:scherroman,项目名称:mugen,代码行数:10,代码来源:Segment.py

示例9: write_video_clips_to_directory

# 需要导入模块: from moviepy import editor [as 别名]
# 或者: from moviepy.editor import VideoClip [as 别名]
def write_video_clips_to_directory(self, video_clips: List[VideoClip], directory: str, *,
                                       file_extension: str = VIDEO_EXTENSION, audio: Union[str, bool] = True,
                                       **kwargs):
        """
        Writes a list of video segments to files in the specified directory
        """
        for index, segment in enumerate(tqdm(video_clips)):
            output_path = os.path.join(directory, str(index) + file_extension)
            self.write_video_clip_to_file(segment, output_path, audio=audio, verbose=False, progress_bar=False,
                                          **kwargs) 
开发者ID:scherroman,项目名称:mugen,代码行数:12,代码来源:VideoWriter.py

示例10: write_video_clip_to_file

# 需要导入模块: from moviepy import editor [as 别名]
# 或者: from moviepy.editor import VideoClip [as 别名]
def write_video_clip_to_file(self, video_clip: VideoClip, output_path: Opt[str] = None, *,
                                 audio: Union[str, bool] = True, verbose: bool = False, progress_bar: bool = True,
                                 **kwargs):
        """
        Writes a video clip to file in the specified directory

        Parameters
        ----------
        video_clip

        output_path

        audio
            Audio for the video clip. Can be True to enable, False to disable, or an external audio file.

        verbose
            Whether output to stdout should include extra information during writing

        progress_bar
            Whether to output progress information to stdout

        kwargs
            List of other keyword arguments to pass to moviepy's write_videofile
        """
        # Prepend crf to ffmpeg_params
        ffmpeg_params = ['-crf', str(self.crf)] + self.ffmpeg_params
        audio_bitrate = str(self.audio_bitrate) + 'k'

        video_clip.write_videofile(output_path, audio=audio,
                                   preset=self.preset, codec=self.codec, audio_codec=self.audio_codec,
                                   audio_bitrate=audio_bitrate, ffmpeg_params=ffmpeg_params, **kwargs, verbose=verbose,
                                   progress_bar=progress_bar)

        return output_path 
开发者ID:scherroman,项目名称:mugen,代码行数:36,代码来源:VideoWriter.py

示例11: compose

# 需要导入模块: from moviepy import editor [as 别名]
# 或者: from moviepy.editor import VideoClip [as 别名]
def compose(self) -> VideoClip:
        """
        Composes the music video into a VideoClip
        """
        segments = [segment.crop_scale(self.dimensions) for segment in self.segments]
        segments = [segment.apply_effects() for segment in segments]

        # Add buffers for crossfaded video segments
        buffered_video_segments = []
        for index, segment in enumerate(segments):
            buffered_video_segments.append(segment)

            if index == len(segments) - 1:
                continue

            next_segment = segments[index + 1]

            for effect in next_segment.effects:
                if isinstance(effect, v_effects.CrossFade):
                    buffer = segment.trailing_buffer(effect.duration)
                    if buffer.audio:
                        buffer = buffer.set_audio(buffer.audio.audio_fadeout(effect.duration))
                    buffered_video_segments.append(buffer)

        segments = buffered_video_segments

        # Build composite video
        composite_video_segments = [segments[0]]
        for index, segment in enumerate(segments[1:]):
            # Start current segment where previous segment ends in composite video
            previous_segment = composite_video_segments[index]
            segment = segment.set_start(previous_segment.end)

            # Apply any crossfade for the current segment
            for effect in segment.effects:
                if isinstance(effect, v_effects.CrossFade):
                    segment = segment.set_start(previous_segment.end - effect.duration)
                    segment = segment.crossfadein(effect.duration)
                    if segment.audio:
                        segment = segment.set_audio(segment.audio.audio_fadein(effect.duration))

            composite_video_segments.append(segment)

        music_video = CompositeVideoClip(composite_video_segments)

        if self.audio_file:
            music_video.audio = AudioFileClip(self.audio_file)

        return music_video 
开发者ID:scherroman,项目名称:mugen,代码行数:51,代码来源:MusicVideo.py


注:本文中的moviepy.editor.VideoClip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。