forked from Zulko/moviepy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditor.py
107 lines (84 loc) · 3.27 KB
/
editor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
"""
This file is meant to make it easy to load the main features of
MoviePy by simply typing:
>>> from moviepy.editor import *
In particular it will load many effects from the video.fx and audio.fx
folders and turn them into VideoClip methods, so that instead of
>>> clip.fx( vfx.resize, 2 ) # or equivalently vfx.resize(clip, 2)
we can write
>>> clip.resize(2)
It also starts a PyGame session (if PyGame is installed) and enables
clip.preview().
"""
# Note that these imports could have been performed in the __init__.py
# file, but this would make the loading of moviepy slower.
# Clips
from .video.io.VideoFileClip import VideoFileClip
from .video.io.ImageSequenceClip import ImageSequenceClip
from .video.VideoClip import VideoClip, ImageClip, ColorClip, TextClip
from .video.compositing.CompositeVideoClip import CompositeVideoClip, clips_array
from .video.compositing.concatenate import concatenate_videoclips, concatenate # concatenate=deprecated
from .audio.AudioClip import AudioClip, CompositeAudioClip, concatenate_audioclips
from .audio.io.AudioFileClip import AudioFileClip
# FX
import moviepy.video.fx.all as vfx
import moviepy.audio.fx.all as afx
import moviepy.video.compositing.transitions as transfx
# Tools
import moviepy.video.tools as videotools
import moviepy.video.io.ffmpeg_tools as ffmpeg_tools
from .video.io.html_tools import ipython_display
from .tools import cvsecs
try:
from .video.io.sliders import sliders
except ImportError:
pass
# The next loop transforms many effects into VideoClip methods so that
# they can be walled with myclip.resize(width=500) instead of
# myclip.fx( vfx.resize, width= 500)
for method in [
"afx.audio_fadein",
"afx.audio_fadeout",
"afx.volumex",
"transfx.crossfadein",
"transfx.crossfadeout",
"vfx.crop",
"vfx.fadein",
"vfx.fadeout",
"vfx.loop",
"vfx.margin",
"vfx.mask_and",
"vfx.mask_inv",
"vfx.mask_or",
"vfx.resize",
"vfx.speedx"
]:
exec("VideoClip.%s = %s"%( method.split('.')[1], method))
for method in ["afx.audio_fadein",
"afx.audio_fadeout",
"afx.audio_loop",
"afx.volumex"
]:
exec("AudioClip.%s = %s"%( method.split('.')[1], method))
#-----------------------------------------------------------------
# Previews: try to import pygame, else make methods which raise
# exceptions saying to install PyGame
# Add methods preview and show (only if pygame installed)
try:
from moviepy.video.io.preview import show, preview
except ImportError:
def preview(self, *args, **kwargs):
"""NOT AVAILABLE : clip.preview requires Pygame installed."""
raise ImportError("clip.preview requires Pygame installed")
def show(self, *args, **kwargs):
"""NOT AVAILABLE : clip.show requires Pygame installed."""
raise ImportError("clip.show requires Pygame installed")
VideoClip.preview = preview
VideoClip.show = show
try:
from moviepy.audio.io.preview import preview
except ImportError:
def preview(self, *args, **kwargs):
""" NOT AVAILABLE : clip.preview requires Pygame installed."""
raise ImportError("clip.preview requires Pygame installed")
AudioClip.preview = preview