Video editing with Python
Update 'dancing_knights' example (#1422)
Álvaro Mondéjara651608fa0ff
diff --git a/examples/dancing_knights.py b/examples/dancing_knights.pyindex c39dcc24..037249d7 100644--- a/examples/dancing_knights.py+++ b/examples/dancing_knights.py@@ -22,9 +22,10 @@ easy to preview and fine-tune each part of the editing."""import os+import sys-from moviepy.audio.tools.cuts import find_audio_periodfrom moviepy.editor import *+from moviepy.audio.tools.cuts import find_audio_periodfrom moviepy.video.tools.cuts import find_video_period# Next lines are for downloading the required videos from Youtube.@@ -33,15 +34,20 @@ from moviepy.video.tools.cuts import find_video_period# https://www.youtube.com/watch?v=zvCvOC2VwDc => knights.mp4# https://www.youtube.com/watch?v=lkY3Ek9VPtg => frontier.mp4-if not os.path.exists("knights.mp4"):- os.system("youtube-dl zvCvOC2VwDc -o knights")- os.system("youtube-dl lkY3Ek9VPtg -o frontier")+if not os.path.exists("knights.mp4") or not os.path.exists("frontier.webm"):+ retcode1 = os.system("youtube-dl zvCvOC2VwDc -o knights")+ retcode2 = os.system("youtube-dl lkY3Ek9VPtg -o frontier")+ if retcode1 != 0 or retcode2 != 0:+ sys.stderr.write(+ "Error downloading videos. Check that you've installed youtube-dl.\n"+ )+ sys.exit(1)+# ==========# LOAD, EDIT, ANALYZE THE AUDIO-audio = (AudioFileClip("frontier.webm").subclip((4, 7), (4, 18))@@ -55,14 +61,13 @@ print("Analyzed the audio, found a period of %.02f seconds" % audio_period)# LOAD, EDIT, ANALYZE THE VIDEO-clip = (- VideoFileClip("./knights.webm", audio=False)+ VideoFileClip("knights.mp4", audio=False).subclip((1, 24.15), (1, 26)).crop(x1=500, x2=1350))-video_period = find_video_period(clip, tmin=0.3)+video_period = find_video_period(clip, start_time=0.3)print("Analyzed the video, found a period of %.02f seconds" % video_period)edited_right = (@@ -82,8 +87,8 @@ dancing_knights = (.subclip(0.3))-# MAKE THE TITLE SCREEN+# MAKE THE TITLE SCREENtxt_title = (TextClip(@@ -105,7 +110,6 @@ title = (# MAKE THE CREDITS SCREEN-txt_credits = """CREDITS