I wanted to make a code that converts video into audio by a button in python
and that is my code:
from tkinter import *
from tkinter.filedialog import askdirectory
from tkinter.filedialog import askopenfile
from moviepy.editor import *
def def_button():
global Mp4
global Mp4_Data
Mp4 = askopenfile()
if str(Mp4.name)[-4:] != ".mp4":
Mp4_Data = Label(root, text="That's NOT a Mp4 Video", font="decorative 9 bold", fg="red").grid(row=9, column=0,
columnspan=3)
else:
inactive_buttons() #function to make the button inactive to avoid double clicks
mp4_frames = AudioFileClip(Mp4.name)
audio = str(Mp4.name).replace(".mp4", ".mp3")
mp4_frames.write_audiofile(audio)
Mp4_Data = Label(root, text="The Audio Is being Uploaded into Video's Path", font="decorative 9 bold", fg="red") #feed back for the user
Mp4_Data.grid(row=9, column=0, columnspan=3)
assert isinstance(mp4_frames, object)
mp4_frames.close()
active_buttons() #function to make the button active after downloading
button = Button(root, text="Convert a Video into Audio", font="decorative 9 bold", width=50, fg="white", bg="#EF0000",
command=def_button)
button.grid(row=10, column=0, columnspan=3)
Mp4_Data = Label(root, text=" ").grid(row=9, column=0, columnspan=3)
but somehow there is a big error output:
File "C:\Users\Stem Asyut\PycharmProjects\pythonProject\venv\lib\site-packages\moviepy\audio\io\readers.py", line 193, in get_frame
result[in_time] = self.buffer[indices]
IndexError: index -100001 is out of bounds for axis 0 with size 0
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 1892, in __call__
return self.func(*args)
File "C:\Users\Stem Asyut\PycharmProjects\pythonProject\YT_Video_Downloader.py", line 115, in def_button6
mp4_frames.write_audiofile(Mp4.name+".mp3")
File "<decorator-gen-45>", line 2, in write_audiofile
File "C:\Users\Stem Asyut\PycharmProjects\pythonProject\venv\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "C:\Users\Stem Asyut\PycharmProjects\pythonProject\venv\lib\site-packages\moviepy\audio\AudioClip.py", line 206, in write_audiofile
return ffmpeg_audiowrite(self, filename, fps, nbytes, buffersize,
File "<decorator-gen-9>", line 2, in ffmpeg_audiowrite
File "C:\Users\Stem Asyut\PycharmProjects\pythonProject\venv\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "C:\Users\Stem Asyut\PycharmProjects\pythonProject\venv\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 166, in ffmpeg_audiowrite
for chunk in clip.iter_chunks(chunksize=buffersize,
File "C:\Users\Stem Asyut\PycharmProjects\pythonProject\venv\lib\site-packages\moviepy\audio\AudioClip.py", line 85, in iter_chunks
yield self.to_soundarray(tt, nbytes=nbytes, quantize=quantize,
File "<decorator-gen-44>", line 2, in to_soundarray
File "C:\Users\Stem Asyut\PycharmProjects\pythonProject\venv\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "C:\Users\Stem Asyut\PycharmProjects\pythonProject\venv\lib\site-packages\moviepy\audio\AudioClip.py", line 127, in to_soundarray
snd_array = self.get_frame(tt)
File "<decorator-gen-11>", line 2, in get_frame
File "C:\Users\Stem Asyut\PycharmProjects\pythonProject\venv\lib\site-packages\moviepy\decorators.py", line 89, in wrapper
return f(*new_a, **new_kw)
File "C:\Users\Stem Asyut\PycharmProjects\pythonProject\venv\lib\site-packages\moviepy\Clip.py", line 93, in get_frame
return self.make_frame(t)
File "C:\Users\Stem Asyut\PycharmProjects\pythonProject\venv\lib\site-packages\moviepy\audio\io\AudioFileClip.py", line 77, in <lambda>
self.make_frame = lambda t: self.reader.get_frame(t)
File "C:\Users\Stem Asyut\PycharmProjects\pythonProject\venv\lib\site-packages\moviepy\audio\io\readers.py", line 205, in get_frame
result[in_time] = self.buffer[indices]
IndexError: index -100001 is out of bounds for axis 0 with size 0
and I don't know why that's happening.
I tried a lot of things and I have the same problem.
SO is there anyone who could help me with that problem because I didn't find anything about that on the internet?
Related
WHAT I'M TRYING TO DO:
Concatenate a few dozen videos from a directory to form one large video. The videos don't have the same size or aspect ratio, so I'd like for the videos to fit (without stretching) in a 1080x1920 frame and just have the background be black.
MY CODE:
I'm getting the following error:
Exception has occurred: ValueError
could not broadcast input array from shape (1080,1920,3) into shape (1080,1920)
when I run the following code (error comes at the commented line):
from moviepy.editor import *
from os import walk, path
INTRO_VIDEO_PATH = r'C:\Users\jack_L\Downloads\INTRO_VIDEO\INTRO.mp4'
VIDEOS_PATH = r'C:\Users\jack_l\Downloads\DOWNLOADS\folder'
myVideos = next(walk(VIDEOS_PATH), (None, None, []))[2]
finalVideo = []
finalVideo.append(VideoFileClip(INTRO_VIDEO_PATH))
for counter in range(len(myVideos)):
myExtension = path.splitext(myVideos[counter])[1]
if myExtension != '.mp4':
continue
myVideo = VideoFileClip(VIDEOS_PATH+'\\'+myVideos[counter])
finalVideo.append(myVideo)
theFinalVideo = concatenate_videoclips(finalVideo, method='compose', bg_color='black')
theFinalVideo.write_videofile(r'C:\Users\jack_l\Downloads\final.mp4') #error at this line
WHAT I KNOW/HAVE BEEN TOLD:
"Each frame is a RGB frame, which has 3 channels, but you are trying to fit it into a Greayscale single channel frame." - Sembei Norimaki. Unfortunately, I'm unsure of how I could fix this.
FULL TRACEBACK:
Traceback (most recent call last):
File "c:\Users\jack_l\Documents\MEME_MAKER\swagGamingMemes.py", line 20, in <module>
theFinalVideo.write_videofile(r'C:\Users\jack_l\Downloads\final.mp4')
File "<decorator-gen-55>", line 2, in write_videofile
File "C:\Users\jack_l\AppData\Roaming\Python\Python39\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "<decorator-gen-54>", line 2, in write_videofile
File "C:\Users\jack_l\AppData\Roaming\Python\Python39\site-packages\moviepy\decorators.py", line 135, in use_clip_fps_by_default
return f(clip, *new_a, **new_kw)
File "<decorator-gen-53>", line 2, in write_videofile
File "C:\Users\jack_l\AppData\Roaming\Python\Python39\site-packages\moviepy\decorators.py", line 22, in convert_masks_to_RGB
return f(clip, *a, **k)
File "C:\Users\jack_l\AppData\Roaming\Python\Python39\site-packages\moviepy\video\VideoClip.py", line 300, in write_videofile
ffmpeg_write_video(self, filename, fps, codec,
File "C:\Users\jack_l\AppData\Roaming\Python\Python39\site-packages\moviepy\video\io\ffmpeg_writer.py", line 220, in ffmpeg_write_video
for t,frame in clip.iter_frames(logger=logger, with_times=True,
File "C:\Users\jack_l\AppData\Roaming\Python\Python39\site-packages\moviepy\Clip.py", line 472, in iter_frames
frame = self.get_frame(t)
File "<decorator-gen-11>", line 2, in get_frame
File "C:\Users\jack_l\AppData\Roaming\Python\Python39\site-packages\moviepy\decorators.py", line 89, in wrapper
return f(*new_a, **new_kw)
File "C:\Users\jack_l\AppData\Roaming\Python\Python39\site-packages\moviepy\Clip.py", line 93, in get_frame
return self.make_frame(t)
File "C:\Users\jack_l\AppData\Roaming\Python\Python39\site-packages\moviepy\video\compositing\CompositeVideoClip.py", line 111, in make_frame
f = c.blit_on(f, t)
File "C:\Users\jack_l\AppData\Roaming\Python\Python39\site-packages\moviepy\video\VideoClip.py", line 564, in blit_on
return blit(img, picture, pos, mask=mask, ismask=self.ismask)
File "C:\Users\jack_l\AppData\Roaming\Python\Python39\site-packages\moviepy\video\tools\drawing.py", line 41, in blit
new_im2[yp1:yp2, xp1:xp2] = blitted
ValueError: could not broadcast input array from shape (1080,1920,3) into shape (1080,1920)
SOLUTION:
Removed the bg_color='black' attribute from the theFinalVideo = concatenate_videoclips(finalVideo, method='compose', bg_color='black') line and it worked.
I recorded a movie with my celphone and I want to increase the movie duration n times. Ex.: If the duration of the movie is 5 seconds, the output movie should have n x 5 seconds of duration, it should be repeated. My goal is to get a 5 seconds movie and repeat n times for 3 hours. I tried with moviepy but it points an error related to the file. I'm trying with moviepy but I'm open to cv2 or any other ideia. This is my code and the error:
from moviepy.editor import *
videoclip = VideoFileClip('VID_20201207_022713542.mp4')
audio = afx.audio_loop(videoclip, nloops=3)
and the error:
runfile('C:/Users/felip/Google Drive/Musica/music1.py', wdir='C:/Users/felip/Google Drive/Musica')
Traceback (most recent call last):
File "C:\Users\felip\Google Drive\Musica\music1.py", line 11, in
audio = afx.audio_loop(videoclip, nloops=3)
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\audio\fx\audio_loop.py", line 28, in audio_loop
return concatenate_audioclips(nloops*[audioclip])
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\audio\AudioClip.py", line 319, in concatenate_audioclips
result = CompositeAudioClip(newclips).set_duration(tt[-1])
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\audio\AudioClip.py", line 287, in init
self.nchannels = max([c.nchannels for c in self.clips])
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\audio\AudioClip.py", line 287, in
self.nchannels = max([c.nchannels for c in self.clips])
AttributeError: 'VideoFileClip' object has no attribute 'nchannels'
EDIT: I tried:
from moviepy.editor import *
clip = VideoFileClip('VID_20201207_022713542.mp4').fx(vfx.loop, n = 2)
clip.write_videofile("output.mp4")```
and received the error message:
runfile('C:/Users/felip/Google Drive/Musica/music1.py', wdir='C:/Users/felip/Google Drive/Musica')
chunk: 0%| | 0/3044 [00:00<?, ?it/s, now=None]Moviepy - Building video output.mp4.
MoviePy - Writing audio in outputTEMP_MPY_wvf_snd.mp3
chunk: 23%|██▎ | 714/3044 [00:02<00:26, 88.42it/s, now=None]Traceback (most recent call last):
File "C:\Users\felip\Google Drive\Musica\music1.py", line 11, in
clip.write_videofile("output.mp4")
File "", line 2, in write_videofile
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "", line 2, in write_videofile
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\decorators.py", line 135, in use_clip_fps_by_default
return f(clip, *new_a, **new_kw)
File "", line 2, in write_videofile
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\decorators.py", line 22, in convert_masks_to_RGB
return f(clip, *a, **k)
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\video\VideoClip.py", line 298, in write_videofile
logger=logger)
File "", line 2, in write_audiofile
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\audio\AudioClip.py", line 210, in write_audiofile
logger=logger)
File "", line 2, in ffmpeg_audiowrite
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 169, in ffmpeg_audiowrite
logger=logger):
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\audio\AudioClip.py", line 86, in iter_chunks
fps=fps, buffersize=chunksize)
File "", line 2, in to_soundarray
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\audio\AudioClip.py", line 127, in to_soundarray
snd_array = self.get_frame(tt)
File "", line 2, in get_frame
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\decorators.py", line 89, in wrapper
return f(*new_a, **new_kw)
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\Clip.py", line 93, in get_frame
return self.make_frame(t)
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\Clip.py", line 136, in
newclip = self.set_make_frame(lambda t: fun(self.get_frame, t))
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\Clip.py", line 187, in
return self.fl(lambda gf, t: gf(t_func(t)), apply_to,
File "", line 2, in get_frame
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\decorators.py", line 89, in wrapper
return f(*new_a, **new_kw)
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\Clip.py", line 93, in get_frame
return self.make_frame(t)
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\audio\io\AudioFileClip.py", line 77, in
self.make_frame = lambda t: self.reader.get_frame(t)
File "C:\Users\felip\Anaconda3\lib\site-packages\moviepy\audio\io\readers.py", line 172, in get_frame
"with clip duration=%d seconds, "%self.duration)
OSError: Error in file VID_20201207_022713542.mp4, Accessing time t=34.51-34.56 seconds, with clip duration=34 seconds,
chunk: 25%|██▌ | 762/3044 [00:19<00:25, 88.42it/s, now=None]
I am using openCV with C++ so I can't give you a python or moviepy code, but here's a idea for your own implementation.
step 1) read target video and save every frame to an image array(Mat class array).
step 2) make a VideoWriter class for save video and write saved frames n times in it.
I have no experience about audio processing, but I guess the same approach would work.
to slow down you can use
ffmpeg -i YOUR_INPUT_MOVIE.mp4 -vf "setpts=5*PTS" YOUR_OUTPUT_MOVIE.mp4
So, I have this very basic script that concatenates two videos, and adds a background sound.
def intro():
voiceoverIntro = AudioFileClip(audio[3]) #get path for intro.mp3
introVideo = []
temp = p1vid + p2vid + p3vid
for x in temp: # add product videos to introVideo if they are longer than intro.mp3
x = VideoFileClip(x)
if x.duration >= voiceoverIntro.duration:
introVideo.append(x)
if len(introVideo) >= 1:
#Get the video and turn off its volume
introBg = introVideo[0].volumex(0).resize((1280,720))
introBg = introBg.set_audio(voiceoverIntro).set_duration(voiceoverIntro.duration)
introBg.reader.close()
introBg.audio.reader.close_proc()
return introBg
And this function creates the second clip
def productThreeOpener(productName):
opener3 = VideoFileClip("media/number3.mp4").volumex(0).resize((1280,720))
text = TextClip(productName,fontsize=60,color='white', font="Dekar")\
.set_pos(("right", "center"))\
.set_duration(3)\
.set_start(2)\
.crossfadein(1)\
.crossfadeout(1)\
.margin(right=200,opacity=0)
opener3 = CompositeVideoClip([opener3, text])
return opener3
Now we just concatenate the two outputs
final_clip = concatenate_videoclips([intro, productThreeOpener], method="compose")
final_clip.resize((1280, 720)).write_videofile("output/intro.mp4", threads=8, fps=24, progress_bar=False)
Running the code above returns this error;
Traceback (most recent call last):
[MoviePy] >>>> Building video output/intro.mp4
File "C:/Users/Akbulut/PycharmProjects/youtubeVideoEditor/vidEditor/sandbox.py", line 145, in <module>
[MoviePy] Writing audio in introTEMP_MPY_wvf_snd.mp3
final_clip.write_videofile("output/intro.mp4", threads=8, fps=24, progress_bar=False)
File "<decorator-gen-51>", line 2, in write_videofile
File "C:\Program Files\Python36\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "<decorator-gen-50>", line 2, in write_videofile
File "C:\Program Files\Python36\lib\site-packages\moviepy\decorators.py", line 137, in use_clip_fps_by_default
return f(clip, *new_a, **new_kw)
File "<decorator-gen-49>", line 2, in write_videofile
File "C:\Program Files\Python36\lib\site-packages\moviepy\decorators.py", line 22, in convert_masks_to_RGB
return f(clip, *a, **k)
File "C:\Program Files\Python36\lib\site-packages\moviepy\video\VideoClip.py", line 318, in write_videofile
progress_bar=progress_bar)
File "<decorator-gen-73>", line 2, in write_audiofile
File "C:\Program Files\Python36\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "C:\Program Files\Python36\lib\site-packages\moviepy\audio\AudioClip.py", line 213, in write_audiofile
progress_bar=progress_bar)
File "<decorator-gen-70>", line 2, in ffmpeg_audiowrite
File "C:\Program Files\Python36\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "C:\Program Files\Python36\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 165, in ffmpeg_audiowrite
ffmpeg_params=ffmpeg_params)
File "C:\Program Files\Python36\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 71, in __init__
self.proc = sp.Popen(cmd, **popen_params)
File "C:\Program Files\Python36\lib\subprocess.py", line 594, in __init__
_cleanup()
File "C:\Program Files\Python36\lib\subprocess.py", line 205, in _cleanup
res = inst._internal_poll(_deadstate=sys.maxsize)
File "C:\Program Files\Python36\lib\subprocess.py", line 1025, in _internal_poll
if _WaitForSingleObject(self._handle, 0) == _WAIT_OBJECT_0:
OSError: [WinError 6] İşleyici geçersiz
Exception ignored in: <bound method FFMPEG_AudioWriter.__del__ of <moviepy.audio.io.ffmpeg_audiowriter.FFMPEG_AudioWriter object at 0x0000000A885019B0>>
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 134, in __del__
self.close()
File "C:\Program Files\Python36\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 122, in close
if self.proc:
AttributeError: 'FFMPEG_AudioWriter' object has no attribute 'proc'
Process finished with exit code 1
I strictly followed MoviePY installation guide, installed it and all of its dependencies about 2 days ago. I work on a 64b Windows machine. Python version 3.6.1
I've been stuck with this error for over a day now, and I don't know what to try.. Any help/advice is highly appreciated.
Thanks.
I am trying to add text to a clip generated by concatenate_videoclips, but I keep getting an error. I have tried to add the text to each clip individually and then concatenate, but I got the same error.
Here is my code:
clip_list = []
for file in movie_maker_directory:
clip = VideoFileClip('C:\dev\movie_maker\{}'.format(file))
if clip.rotation != 0:
clip = clip.rotate(-clip.rotation)
clip = clip.resize(height=1080)
clip_list.append(clip)
final_clip = concatenate_videoclips(clip_list, method="compose")
text = TextClip('Documentary Title', fontsize=5).set_position(('top', 'left'))
final_clip = CompositeVideoClip([text, clip])
final_clip.write_videofile("C:\dev\movie_maker\my_concatenation.mp4")
And here is the error message:
File "C:/dev/movie_compilator.py", line 58, in <module>
final_clip.write_videofile("C:\dev\movie_maker\my_concatenation.mp4")
File "<decorator-gen-51>", line 2, in write_videofile
File "C:\Local\Programs\Python\Python35\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "<decorator-gen-50>", line 2, in write_videofile
File "C:\Local\Programs\Python\Python35\lib\site-packages\moviepy\decorators.py", line 137, in use_clip_fps_by_default
return f(clip, *new_a, **new_kw)
File "<decorator-gen-49>", line 2, in write_videofile
File "C:\Local\Programs\Python\Python35\lib\site-packages\moviepy\decorators.py", line 22, in convert_masks_to_RGB
return f(clip, *a, **k)
File "C:\Local\Programs\Python\Python35\lib\site-packages\moviepy\video\VideoClip.py", line 349, in write_videofile
progress_bar=progress_bar)
File "C:\Local\Programs\Python\Python35\lib\site-packages\moviepy\video\io\ffmpeg_writer.py", line 209, in ffmpeg_write_video
fps=fps, dtype="uint8"):
File "C:\Local\Programs\Python\Python35\lib\site-packages\tqdm\_tqdm.py", line 833, in __iter__
for obj in iterable:
File "C:\Local\Programs\Python\Python35\lib\site-packages\moviepy\Clip.py", line 475, in generator
frame = self.get_frame(t)
File "<decorator-gen-14>", line 2, in get_frame
File "C:\Local\Programs\Python\Python35\lib\site-packages\moviepy\decorators.py", line 89, in wrapper
return f(*new_a, **new_kw)
File "C:\Local\Programs\Python\Python35\lib\site-packages\moviepy\Clip.py", line 95, in get_frame
return self.make_frame(t)
File "C:\Local\Programs\Python\Python35\lib\site-packages\moviepy\video\compositing\CompositeVideoClip.py", line 110, in make_frame
f = c.blit_on(f, t)
File "C:\Local\Programs\Python\Python35\lib\site-packages\moviepy\video\VideoClip.py", line 603, in blit_on
pos[0] = D[pos[0]]
KeyError: 'top'
I think you have your positioning reversed. Try this instead:
text = TextClip('Documentary Title', fontsize=5).set_position(('left', 'top'))
from tkinter import *
import pytube
import threading
def download():
link = test_url.get()
yt = pytube.YouTube(link)
videos = yt.get_videos()
n = quality.get()
vid = videos[n - 1]
destination = destination_test.get()
vid.download(destination)
def test():
threading.Thread(target=download()).start()
root = Tk()
test_url = StringVar()
quality = IntVar()
destination_test = StringVar()
url_label = Label(text='Enter Url')
quality_label = Label(text='quality')
url_label.grid(row=0, column=0)
quality_label.grid(row=1, column=0)
destination_label = Label(text='Destination')
destination_label.grid(row=2, column=0)
url_entry = Entry(textvariable=test_url)
url_entry.grid(row=0, column=1)
quality_entry = Entry(textvariable=quality)
quality_entry.grid(row=1, column=1)
destination_entry = Entry(textvariable=destination_test)
destination_entry.grid(row=2, column=1)
download_button = Button(text='download', command=test())
download_button.grid(row=3, column=1)
root.mainloop()
Traceback (most recent call last): File "C:\Program Files\JetBrains\PyCharm Community Edition
2017.1.4\helpers\pycharm_jb_unittest_runner.py", line 35, in
main(argv=args, module=None, testRunner=unittestpy.TeamcityTestRunner, buffer=not
JB_DISABLE_BUFFERING) File "C:\Python36\lib\unittest\main.py", line
93, in init
self.parseArgs(argv) File "C:\Python36\lib\unittest\main.py", line 140, in parseArgs
self.createTests() File "C:\Python36\lib\unittest\main.py", line 147, in createTests
self.module) File "C:\Python36\lib\unittest\loader.py", line 219, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names] File "C:\Python36\lib\unittest\loader.py", line 219, in
suites = [self.loadTestsFromName(name, module) for name in names] File "C:\Python36\lib\unittest\loader.py", line 153, in
loadTestsFromName
module = import(module_name) File "C:\Users\Matthew\PycharmProjects\test\test.py", line 37, in
download_button = Button(text='download', command=test()) File "C:\Users\Matthew\PycharmProjects\test\test.py", line 19, in test
threading.Thread(target=download()).start() File "C:\Users\Matthew\PycharmProjects\test\test.py", line 13, in download
vid = videos[n - 1] IndexError: list index out of range
Because the value of your variable 'n' either equals to 0, or it's larger than your number of videos by 2 or more.
Whatever quality.get() does, whatever quality variable is, n=quality.get() is the line that eventually causes error...