I had again one problem that I couldn’t solve with google…
This is an excerpt from the code of my video editor:
global media_imports, maximum_width, maximum_height
video_path = askopenfilename(filetypes =[('Video Files', '*.mp4')])
loaded_video = cv2.VideoCapture(video_path)
return, frame = loaded_video.read()
if frame.shape[0] / maximum_height > frame.shape[1] / maximum_width:
height = maximum_height
width = int(frame.shape[1] * height / frame.shape[0])
else:
width = maximum_width
height = int(frame.shape[0] * width / frame.shape[1])
frame = cv2.resize(frame, (width, height))
tkinter_image = ImageTk.PhotoImage(image=Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)))
thumbnail = Label(media, image = tkinter_image)
if media_imports % 2 == 0:
thumbnail.place(x = window.winfo_screenwidth() * 0.01, y = window.winfo_screenheight() / 10 + (window.winfo_screenwidth() * 0.01 + maximum_height) * (int(media_imports / 2)))
else:
thumbnail.place(x = window.winfo_screenwidth() * 0.11, y = window.winfo_screenheight() / 10 + (window.winfo_screenwidth() * 0.01 + maximum_height) * (int(media_imports / 2)))
media_imports += 1
I already tried to double the line
return, frame = loaded_video.read()
beacause maybe only the first frame is white but that didn’t work also…
New contributor
Alex is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.