Reputation: 59
def open_file():
b_text.set("Loading")
files = askopenfile(initialdir = ".",parent=root ,title="choose a video",filetype=[("Video Files","*.mp4")])
if files:
print("File was loaded")
files.without_audio().preview()
This is the error i am facing
Traceback (most recent call last):
File "C:\Users\felix\anaconda3\lib\tkinter\__init__.py", line 1883, in __call__
return self.func(*args)
File "c:/Users/felix/Desktop/video editor/new.py", line 27, in open_file
b=Button(root,textvariable=b_text,relief=GROOVE,bg="#232323",fg="white", command=open_file)
AttributeError: '_io.TextIOWrapper' object has no attribute 'without_audio'
Upvotes: 0
Views: 172
Reputation: 32124
You must execute VideoFileClip
before previewing.
The method askopenfile
selects a file.
Execute clip = VideoFileClip(file.name)
for creating VideoFileClip
object.
Then you can execute clip.without_audio().preview()
.
For more details see: MoviePy – Previewing a Video Clip.
When executing the code, I was getting an error message:
clip.preview requires Pygame installed
I has to install pygame.
Here is a code sample for selecting and previewing a video file:
from tkinter.filedialog import askopenfile
from moviepy.editor import *
file = askopenfile(initialdir = ".", title="choose a video", filetype=[("Video Files","*.mp4")])
if file:
print("File was loaded")
# https://www.geeksforgeeks.org/moviepy-previewing-a-video-clip/
# Loading video file
clip = VideoFileClip(file.name)
# previewing the clip at fps = 10
clip.without_audio().preview(fps=10)
Note:
Since the example is "stand alone" application, I had to remove the parent
argument (but you should keep the parent=root
argument).
Upvotes: 0