0

I am trying to use moviepy in Python to edit some videos, however I can't get basic code to run. The moviepy library installs just fine, and I have ffmpeg installed.

I tried running the following example code from moviepy, just replacing the initial video file name with my own:

from moviepy import *

#CURRENT ISSUE: 'VideoFileClip not defined'

video = VideoFileClip("bdt.mkv").subclip(50,60)

# Make the text. Many more options are available.
txt_clip = ( TextClip("My Holidays 2013",fontsize=70,color='white')
             .with_position('center')
             .with_duration(10) )

result = CompositeVideoClip([video, txt_clip]) # Overlay text on video
result.write_videofile("myHolidays_edited.webm",fps=25) # Many options...

instead of producing a video, it kicked back this error:

C:\Code\Projects\Playground\mp-test>python main.py
Traceback (most recent call last):
  File "C:\Code\Projects\Playground\mp-test\main.py", line 5, in <module>
    video = VideoFileClip("bdt.mkv").subclip(50,60)
            ^^^^^^^^^^^^^
NameError: name 'VideoFileClip' is not defined

I have also tried it with a '*.mp4' file, and received the same results.

any help would be appreciated!

  • There is a comment below that example on Git, 'This example uses the new 2.x API, for MoviePy 1.0.3.' Maybe try `from moviepy.editor import *` – Camden Mar 05 '23 at 11:13

1 Answers1

1
There is a comment below that example on Git, 'This example uses the new 2.x 
API, for MoviePy 1.0.3.' Maybe try from moviepy.editor import *

from Camden's comment above. Thanks Camden!