-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* more api changes
- Loading branch information
Showing
54 changed files
with
580 additions
and
473 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 13 additions & 9 deletions
22
docs/_static/code/user_guide/compositing/CompositeAudioClip.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
from moviepy import * | ||
"""Let's first concatenate (one after the other) then composite | ||
(on top of each other) three audio clips.""" | ||
|
||
from moviepy import AudioFileClip, CompositeAudioClip, concatenate_audioclips | ||
|
||
# We load all the clips we want to compose | ||
aclip1 = AudioFileClip("example.wav") | ||
aclip2 = AudioFileClip("example2.wav") | ||
aclip3 = AudioFileClip("example3.wav") | ||
clip1 = AudioFileClip("example.wav") | ||
clip2 = AudioFileClip("example2.wav") | ||
clip3 = AudioFileClip("example3.wav") | ||
|
||
# All clip will play one after the other | ||
concat = concatenate_audioclips([aclip1, aclip2, aclip3]) | ||
concat = concatenate_audioclips([clip1, clip2, clip3]) | ||
|
||
# We will play aclip1, then ontop of it aclip2 after 5s, and the aclip3 on top of both after 9s | ||
# We will play clip1, then on top of it clip2 starting at t=5s, | ||
# and clip3 on top of both starting t=9s | ||
compo = CompositeAudioClip( | ||
[ | ||
aclip1.with_volume_scaled(1.2), | ||
aclip2.with_start(5), # start at t=5s | ||
aclip3.with_start(9), | ||
clip1.with_volume_scaled(1.2), | ||
clip2.with_start(5), # start at t=5s | ||
clip3.with_start(9), | ||
] | ||
) |
10 changes: 7 additions & 3 deletions
10
docs/_static/code/user_guide/compositing/CompositeVideoClip.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
from moviepy import * | ||
"""Let's stack three video clips on top of each other with | ||
CompositeVideoClip.""" | ||
|
||
from moviepy import VideoFileClip, CompositeVideoClip | ||
|
||
# We load all the clips we want to compose | ||
clip1 = VideoFileClip("example.mp4") | ||
clip2 = VideoFileClip("example2.mp4").subclipped(0, 1) | ||
clip3 = VideoFileClip("example3.mp4") | ||
clip3 = VideoFileClip("example.mp4") | ||
|
||
# We concatenate them and write theme stacked on top of each other, with clip3 over clip2 over clip1 | ||
# We concatenate them and write theme stacked on top of each other, | ||
# with clip3 over clip2 over clip1 | ||
final_clip = CompositeVideoClip([clip1, clip2, clip3]) | ||
final_clip.write_videofile("final_clip.mp4") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,15 @@ | ||
from moviepy import * | ||
"""In this example, we will concatenate two clips with a 1-second | ||
crossfadein of the second clip.""" | ||
|
||
from moviepy import VideoFileClip, CompositeVideoClip, vfx | ||
|
||
# We load all the clips we want to compose | ||
clip1 = VideoFileClip("example.mp4") | ||
clip2 = VideoFileClip("example2.mp4").subclipped(0, 1) | ||
|
||
# Clip2 will be on top of clip1 for 1s | ||
clip1 = clip1.with_end(2) | ||
clip2 = clip2.with_start(1) | ||
|
||
# We will add a crossfadein on clip2 for 1s | ||
# As the other effects, transitions are added to Clip methods at runtime | ||
clip2 = clip2.with_effects([vfx.CrossFadeIn(1)]) | ||
|
||
clip2 = VideoFileClip("example2.mp4") | ||
|
||
# We write the result | ||
final_clip = CompositeVideoClip([clip1, clip2]) | ||
clips = [ | ||
clip1.with_end(2), | ||
clip2.with_start(1).with_effects([vfx.CrossFadeIn(1)]), | ||
] | ||
final_clip = CompositeVideoClip(clips) | ||
final_clip.write_videofile("final_clip.mp4") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
"""Let's invert the green and blue channels of a video.""" | ||
|
||
from moviepy import VideoFileClip | ||
import numpy | ||
|
||
|
12 changes: 7 additions & 5 deletions
12
docs/_static/code/user_guide/effects/modify_copy_example.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
# Import everything needed to edit video clips | ||
from moviepy import * | ||
from moviepy import VideoFileClip | ||
|
||
# Load example.mp4 | ||
clip = VideoFileClip("example.mp4") | ||
|
||
# This does nothing, as multiply_volume will return a copy of clip which you will loose immediatly as you dont store it | ||
# This does nothing, as multiply_volume will return a copy of clip | ||
# which you will loose immediatly as you dont store it | ||
# If you was to render clip now, the audio would still be at full volume | ||
clip.with_volume_scaled(0.1) | ||
|
||
# This create a copy of clip in clip_whisper with a volume of only 10% the original, but does not modify the original clip | ||
# This create a copy of clip in clip_whisper with a volume of only 10% the original, | ||
# but does not modify the original clip | ||
# If you was to render clip right now, the audio would still be at full volume | ||
# If you was to render clip_whisper, the audio would be a 10% of the original volume | ||
clip_whisper = clip.with_volume_scaled(0.1) | ||
|
||
# This replace the original clip with a copy of it where volume is only 10% of the original | ||
# If you was to render clip now, the audio would be at 10% | ||
# This replace the original clip with a copy of it where volume is only 10% of | ||
# the original. If you was to render clip now, the audio would be at 10% | ||
# The original clip is now lost | ||
clip = clip.with_volume_scaled(0.1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
from moviepy import * | ||
from moviepy import AudioClip | ||
import numpy as np | ||
|
||
# Producing a sinewave of 440 Hz -> note A | ||
frame_function_audio = lambda t: np.sin(440 * 2 * np.pi * t) | ||
|
||
# AUDIO CLIPS | ||
clip = AudioClip(frame_function_audio, duration=3) | ||
def audio_frame(t): | ||
"""Producing a sinewave of 440 Hz -> note A""" | ||
return np.sin(440 * 2 * np.pi * t) | ||
|
||
|
||
audio_clip = AudioClip(frame_function=audio_frame, duration=3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
from moviepy import * | ||
from moviepy import ColorClip | ||
|
||
myclip = ColorClip( | ||
size=(200, 100), color=(255, 0, 0), duration=1 | ||
) # Color is passed as a RGB tuple | ||
myclip.write_videofile( | ||
"result.mp4", fps=1 | ||
) # We really dont need more than 1 fps do we ? | ||
# Color is passed as a RGB tuple | ||
myclip = ColorClip(size=(200, 100), color=(255, 0, 0), duration=1) | ||
# We really dont need more than 1 fps do we ? | ||
myclip.write_videofile("result.mp4", fps=1) |
Oops, something went wrong.