Tessando
asked on
Assistance Fixing MoviePY Python Error "NameError: name 'video' is not defined"
I am following this AWS Tutorial on how to create Video subtitles. Per the suggestions in the write-up I'm using Windows (in my case a Server 2019 VM) and Python. I am following the directions perfectly, but when I get to Step 10, in which I test MoviePY, I get the following error:
Thanks for your help!
NameError: name 'video' is not defined
I've done some research and it seems like I do need to define 'video' in Python, but what I'm not aware of is:
- Where I make this adjustment? E.g. to what configuration file?
- What I put into the Configuration file in order to fix this error?
Thanks for your help!
ASKER
Ah, yes. Thank you David. I'm attempting to follow the tutorial listed in the AWS doc in order to test MoviePy. In this test case, I'm taking an existing MP4 file, reducing the volume and writing the output as a WebM file. Here is the test code that produces the error I mentioned in the opening question:
Hopefully something is clear from this. Thanks!
# Import everything needed to edit video clips
from moviepy.editor import *
# Load .mp4 and select the subclip 00:00:50 - 00:00:60
clip = VideoFileClip("TEMP_VTT-MS-Test.mp4").subclip(50,60)
# Reduce the audio volume (volume x 0.8)
clip = clip.volumex(0.8)
# Write the result to a file (many options available !)
video.write_videofile("TEMP_VTT-MS-Test.webm")
Hopefully something is clear from this. Thanks!
Noted. Can you rename the file below and try again?
clip = VideoFileClip("mstemp.mp4").subclip(50,60)
ASKER
Thank you, David. I renamed the file that and changed the script, but I'm getting the same error. Here is the full error and path:
Thanks again for your help.
C:\Program Files\ImageMagick-7.1.0-Q16-HDRI\TEMP_TestMoviePY>moviepy-test.py
Traceback (most recent call last):
File "C:\Program Files\ImageMagick-7.1.0-Q16-HDRI\TEMP_TestMoviePY\moviepy-test.py", line 20, in <module>
video.write_videofile("mstemp.webm")
NameError: name 'video' is not defined
Thanks again for your help.
can I know your current working path?
import os
path = os.getcwd()
print(path)
ASKER
The current working path is:
C:\Program Files\ImageMagick-7.1.0-Q16-HDRI\TEMP_TestMoviePY
C:\Program Files\ImageMagick-7.1.0-Q16-HDRI\TEMP_TestMoviePY
Noted. Then, you need to adjust your current working path.
import os
# change the current directory to the directory where the running script file (.py)
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Import everything needed to edit video clips
from moviepy.editor import *
# Load .mp4 and select the subclip 00:00:50 - 00:00:60
clip = VideoFileClip("mstemp.mp4").subclip(50,60)
# Reduce the audio volume (volume x 0.8)
clip = clip.volumex(0.8)
# Write the result to a file (many options available !)
video.write_videofile("TEMP_VTT-MS-Test.webm")
ASKER
Thanks David - I added the import command to the top of the script but I'm getting the same error and no results (e.g. no WebM file). Below is the new script I'm running, perhaps I missing something.
Does this script look correct to you (for what you intended me to run)?
import os
# change the current directory to the directory where the running script file (.py)
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Import everything needed to edit video clips
from moviepy.editor import *
# Load myHolidays.mp4 and select the subclip 00:00:50 - 00:00:60
clip = VideoFileClip("mstemp.mp4").subclip(50,60)
# Reduce the audio volume (volume x 0.8)
clip = clip.volumex(0.8)
# Write the result to a file (many options available !)
video.write_videofile("mstemp.webm")
Does this script look correct to you (for what you intended me to run)?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can you share some related working code here to further understand of your actual error?