ターミナルmp4からmp3へのコンバーターを作りました。UIバージョンを作成しようとしていますが、機能しません。tkinter入力を行ったので、ビデオの名前を入力に入力すると、変換されるはずです。しかし、UI入力を作成するには、tkinterを使用する必要がありますが、ムービーコードにtkinter入力を使用しようとすると、ファイルの名前として入力が使用されます。エラーは呼ばれます:OSError: MoviePy error: the file could not be found! Please check that you entered the correct path.
これを修正する方法はありますか?
from tkinter import *
from moviepy.editor import *
window = Tk()
e = Entry(window, width=50)
e.pack()
def myClick():
myLabel = Label(window, text="Converting the file named : " + e.get())
myLabel.pack()
myButton = Button(window, text="Convert", command=myClick)
video = e.get()
myButton.pack()
mp4_file = video
mp3_file = "{}.mp3".format(mp4_file)
videoClip = VideoFileClip(mp4_file)
audioclip = videoClip.audio
audioclip.write_audiofile(mp3_file)
audioclip.close()
videoClip.close()
window.mainloop()
ロジックを関数に移動する必要があります。
from tkinter import *
from moviepy.editor import *
def myClick():
myLabel = Label(window, text="Converting the file named : " + e.get())
myLabel.pack()
video = e.get()
mp4_file = video
mp3_file = "{}.mp3".format(mp4_file)
videoClip = VideoFileClip(mp4_file)
audioclip = videoClip.audio
audioclip.write_audiofile(mp3_file)
audioclip.close()
videoClip.close()
window = Tk()
e = Entry(window, width=50)
e.pack()
myButton = Button(window, text="Convert", command=myClick)
myButton.pack()
window.mainloop()
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加