Skip to content

Video editing with Python

fix few examples

osaajanib434d2e63abe
diff --git a/docs/_static/code/getting_started/quick_presentation/basic_example.py b/docs/_static/code/getting_started/quick_presentation/basic_example.py
index a85473c1..109e4c07 100644
--- a/docs/_static/code/getting_started/quick_presentation/basic_example.py
+++ b/docs/_static/code/getting_started/quick_presentation/basic_example.py
@@ -2,20 +2,17 @@
from moviepy import *
# Load file example.mp4 and extract only the subclip from 00:00:10 to 00:00:20
-clip = VideoFileClip("long_examples/example.mp4").with_subclip(10, 20)
+clip = VideoFileClip("long_examples/example2.mp4").with_subclip(10, 20)
# Reduce the audio volume to 80% of his original volume
clip = clip.with_multiply_volume(0.8)
# Generate a text clip. You can customize the font, color, etc.
-txt_clip = TextClip(font="example.ttf", text="My Holidays 2013", font_size=70, color='white')
+txt_clip = TextClip(font="example.ttf", text="Big Buck Bunny", font_size=70, color='white')
# Say that you want it to appear for 10s at the center of the screen
txt_clip = txt_clip.with_position('center').with_duration(10)
-print(clip.mask)
-print(txt_clip.mask)
-
# Overlay the text clip on the first video clip
video = CompositeVideoClip([clip, txt_clip])
diff --git a/docs/_static/code/user_guide/compositing/CompositeVideoClip.py b/docs/_static/code/user_guide/compositing/CompositeVideoClip.py
index cca966e6..33e3ccfc 100644
--- a/docs/_static/code/user_guide/compositing/CompositeVideoClip.py
+++ b/docs/_static/code/user_guide/compositing/CompositeVideoClip.py
@@ -1,9 +1,9 @@
from moviepy import *
# We load all the clips we want to compose
clip1 = VideoFileClip("example.mp4")
-clip2 = VideoFileClip("example2.mp4").with_subclip(0,1)
+clip2 = VideoFileClip("example2.mp4").with_subclip(0, 1)
clip3 = VideoFileClip("example3.mp4")
# 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 = CompositeVideoClip([clip1, clip2, clip3])
final_clip.write_videofile("final_clip.mp4")
\ No newline at end of file
diff --git a/docs/_static/code/user_guide/compositing/concatenate.py b/docs/_static/code/user_guide/compositing/concatenate.py
index e2b2966f..f10fc48e 100644
--- a/docs/_static/code/user_guide/compositing/concatenate.py
+++ b/docs/_static/code/user_guide/compositing/concatenate.py
@@ -2,7 +2,7 @@ from moviepy import VideoFileClip, concatenate_videoclips
# We load all the clips we want to concatenate
clip1 = VideoFileClip("example.mp4")
-clip2 = VideoFileClip("example2.mp4").with_subclip(0,1)
+clip2 = VideoFileClip("example2.mp4").with_subclip(0, 1)
clip3 = VideoFileClip("example3.mp4")
# We concatenate them and write the result
diff --git a/docs/_static/code/user_guide/effects/using_with_methods.py b/docs/_static/code/user_guide/effects/using_with_methods.py
index 3ad601fa..422fb5ff 100644
--- a/docs/_static/code/user_guide/effects/using_with_methods.py
+++ b/docs/_static/code/user_guide/effects/using_with_methods.py
@@ -1,17 +1,6 @@
from moviepy import VideoFileClip
from moviepy import vfx, afx
-# from os import listdir
-# from os.path import isfile, join
-
-# import os
-# dir = os.path.dirname(__file__)
-# onlyfiles = [f for f in listdir(dir) if isfile(join(dir, f))]
-
-# import pathlib
-# print(globals())
-# print(pathlib.Path('./').resolve())
-# print(onlyfiles)
myclip = VideoFileClip("example.mp4")
myclip = myclip.with_end(5) # stop the clip after 5 sec
myclip = myclip.without_audio() # remove the audio of the clip
diff --git a/docs/_static/code/user_guide/rendering/display_in_notebook.py b/docs/_static/code/user_guide/rendering/display_in_notebook.py
index 580183ea..f9630958 100644
--- a/docs/_static/code/user_guide/rendering/display_in_notebook.py
+++ b/docs/_static/code/user_guide/rendering/display_in_notebook.py
@@ -14,7 +14,7 @@ my_image_clip.display_in_notebook() # embeds an image
my_audio_clip.display_in_notebook() # embeds a sound
# We can display only a snaphot of a video
-my_video_clip.display_in_notebook(t=15)
+my_video_clip.display_in_notebook(t=1)
# We can provide any valid HTML5 option as keyword argument
# For instance, if the clip is too big, we can set width
diff --git a/docs/_static/code/user_guide/rendering/save_frame.py b/docs/_static/code/user_guide/rendering/save_frame.py
index 743dad34..4c16c9d2 100644
--- a/docs/_static/code/user_guide/rendering/save_frame.py
+++ b/docs/_static/code/user_guide/rendering/save_frame.py
@@ -2,4 +2,4 @@ from moviepy import *
# We load all the clips we want to compose
myclip = VideoFileClip("example.mp4")
-myclip.save_frame("result.png", t=5) # Save frame at 5 sec
+myclip.save_frame("result.png", t=1) # Save frame at 1 sec
diff --git a/docs/_static/code/user_guide/rendering/show.py b/docs/_static/code/user_guide/rendering/show.py
index 1fade8a0..9caca29f 100644
--- a/docs/_static/code/user_guide/rendering/show.py
+++ b/docs/_static/code/user_guide/rendering/show.py
@@ -5,8 +5,8 @@ myclip = VideoFileClip('./example.mp4')
# We show the first frame of our clip
myclip.show()
-# We show the frame at point 00:00:30 of our clip
-myclip.show(30)
+# We show the frame at point 00:00:01.5 of our clip
+myclip.show(1.5)
# We want to see our clip without applying his mask
-myclip.show(30, with_mask=False)
+myclip.show(1.5, with_mask=False)
diff --git a/docs/_static/code/user_guide/rendering/write_gif.py b/docs/_static/code/user_guide/rendering/write_gif.py
index a11ec4bc..14fb4bbb 100644
--- a/docs/_static/code/user_guide/rendering/write_gif.py
+++ b/docs/_static/code/user_guide/rendering/write_gif.py
@@ -1,6 +1,6 @@
from moviepy import *
-myclip = VideoFileClip("example.mp4").with_subclip(0, 10)
+myclip = VideoFileClip("example.mp4").with_subclip(0, 2)
# Here we just save as GIF
myclip.write_gif("result.gif")
diff --git a/docs/_static/code/user_guide/rendering/write_videofile.py b/docs/_static/code/user_guide/rendering/write_videofile.py
index b63fbe52..288f5023 100644
--- a/docs/_static/code/user_guide/rendering/write_videofile.py
+++ b/docs/_static/code/user_guide/rendering/write_videofile.py
@@ -1,7 +1,7 @@
from moviepy import *
# We load all the clips we want to compose
-background = VideoFileClip("example.mp4").with_subclip(0, 10)
+background = VideoFileClip("long_examples/example2.mp4").with_subclip(0, 10)
title = TextClip("./example.ttf", text="Big Buck Bunny", font_size=80, color="#fff", text_align="center", duration=3).with_position(("center", "center"))
# We make our final clip through composition
@@ -15,7 +15,7 @@ final_clip.write_videofile("result.mp4")
# Here we save as MP4, but we set the FPS of the clip to our own, here 24 fps, like cinema
final_clip.write_videofile("result24fps.mp4", fps=24)
-# Now we save as WEBM instead, and we want tu use codec libvpx.
+# Now we save as WEBM instead, and we want tu use codec libvpx-vp9 (usefull when mp4 + transparency).
# We also want ffmpeg compression optimisation as minimal as possible. This will not change
# the video quality and it will decrease time for encoding, but increase final file size a lot.
# Finally, we want ffmpeg to use 4 threads for video encoding. You should probably leave that
diff --git a/docs/_static/code/user_guide/rendering/write_videofile_duration.py b/docs/_static/code/user_guide/rendering/write_videofile_duration.py
index 76302d8a..a3945fe2 100644
--- a/docs/_static/code/user_guide/rendering/write_videofile_duration.py
+++ b/docs/_static/code/user_guide/rendering/write_videofile_duration.py
@@ -10,4 +10,4 @@ except :
print('Cannot write a video without duration')
# By calling with_duration on our clip, we fix the problem! We also need to set fps
-my_clip.with_duration(5).write_videofile("result.mp4", fps=1)
\ No newline at end of file
+my_clip.with_duration(2).write_videofile("result.mp4", fps=1)
\ No newline at end of file