Python moviepy.editor.VideoClip() Examples
The following are 27
code examples of moviepy.editor.VideoClip().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
moviepy.editor
, or try the search function
.
Example #1
Source File: utils.py From Robust-Conditional-GAN with MIT License | 6 votes |
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)
Example #2
Source File: utils.py From WGAN-GP-tensorflow with MIT License | 6 votes |
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)
Example #3
Source File: utils.py From PacGAN with MIT License | 6 votes |
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)
Example #4
Source File: utils.py From PacGAN with MIT License | 6 votes |
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)
Example #5
Source File: utils.py From PacGAN with MIT License | 6 votes |
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)
Example #6
Source File: utils.py From PacGAN with MIT License | 6 votes |
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)
Example #7
Source File: utils.py From sText2Image with MIT License | 6 votes |
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)
Example #8
Source File: utils.py From memoryGAN with MIT License | 6 votes |
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)
Example #9
Source File: utils.py From visual-analogy-tensorflow with MIT License | 6 votes |
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)
Example #10
Source File: utils.py From Nonlinear_Face_3DMM with Apache License 2.0 | 6 votes |
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)
Example #11
Source File: utils.py From Cross-Modal-Projection-Learning with MIT License | 6 votes |
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)
Example #12
Source File: utils.py From ALOCC-CVPR2018 with MIT License | 6 votes |
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)
Example #13
Source File: utils.py From research with BSD 3-Clause "New" or "Revised" License | 6 votes |
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)
Example #14
Source File: utils.py From HistoGAN with GNU General Public License v3.0 | 6 votes |
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)
Example #15
Source File: utils.py From DeepHDR with MIT License | 6 votes |
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)
Example #16
Source File: utils.py From Creative-Adversarial-Networks with MIT License | 6 votes |
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)
Example #17
Source File: utils.py From AnoGAN-tf with MIT License | 6 votes |
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)
Example #18
Source File: utils.py From WaterGAN with MIT License | 6 votes |
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)
Example #19
Source File: dcgan_utils.py From csgm with MIT License | 6 votes |
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)
Example #20
Source File: utils.py From CausalGAN with MIT License | 6 votes |
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)
Example #21
Source File: utils.py From opt-mmd with BSD 3-Clause "New" or "Revised" License | 6 votes |
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)
Example #22
Source File: movie.py From neat-python with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #23
Source File: VideoWriter.py From mugen with MIT License | 5 votes |
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
Example #24
Source File: VideoWriter.py From mugen with MIT License | 5 votes |
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)
Example #25
Source File: Segment.py From mugen with MIT License | 5 votes |
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)
Example #26
Source File: input_static_pic_to_gif2_for_class.py From face-detection-induction-course with MIT License | 5 votes |
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)
Example #27
Source File: MusicVideo.py From mugen with MIT License | 4 votes |
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