-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_ffmpeg.py
55 lines (48 loc) · 1.5 KB
/
get_ffmpeg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from urllib.request import urlopen, urlretrieve
from urllib.error import URLError, HTTPError
import os
import stat
import tkinter.messagebox as mbox
FFMPEG_URL = "https://github.com/imageio/imageio-binaries/raw/master/ffmpeg/ffmpeg-osx-v3.2.4"
def get_ffmpeg(mqapp):
if internet_on() == False:
mqapp.popup.destroy()
mbox.showinfo("Error!", "No internet connection or File not Found.\n\n"
"Please provide manual installation of ffmpeg.")
return False
# get the file
try:
urlretrieve(FFMPEG_URL, "/tmp/ffmpeg.osx")
except URLError as e:
mqapp.popup.destroy()
mbox.showinfo("Error!", e.reason)
return False
except HTTPError as e:
mqapp.popup.destroy()
mbox.showinfo("Error!", e.msg)
return False
# move the file
try:
os.makedirs(mqapp.path_OSX)
except:
pass
try:
os.rename("/tmp/ffmpeg.osx", mqapp.path_OSX+"/ffmpeg.osx")
except OSError as e:
mqapp.popup.destroy()
mbox.showinfo("Error!", e.output)
return False
# make the file executable
st = os.stat(mqapp.path_OSX+"/ffmpeg.osx")
os.chmod(mqapp.path_OSX+"/ffmpeg.osx", st.st_mode | stat.S_IEXEC)
mqapp.set_ffmpegversion()
mqapp.popup.destroy()
# check if we are connected to internet
def internet_on():
try:
urlopen(FFMPEG_URL, timeout=2)
return True
except URLError as err:
return False
except HTTPError as e:
return False