-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresource_path.py
More file actions
49 lines (40 loc) · 1.39 KB
/
resource_path.py
File metadata and controls
49 lines (40 loc) · 1.39 KB
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
import sys
import os
def get_ffmpeg_path():
"""Get the correct path to FFmpeg executable"""
if hasattr(sys, '_MEIPASS'):
# Running from PyInstaller bundle
bundle_dir = sys._MEIPASS
ffmpeg_path = os.path.join(bundle_dir, "ffmpeg.exe")
if os.path.exists(ffmpeg_path):
return ffmpeg_path
# Check current directory
ffmpeg_path = os.path.join(os.getcwd(), "ffmpeg.exe")
if os.path.exists(ffmpeg_path):
return ffmpeg_path
# Check system PATH
try:
subprocess.run(["ffmpeg", "-version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
return "ffmpeg"
except:
pass
return None
def get_ffprobe_path():
"""Get the correct path to FFprobe executable"""
if hasattr(sys, '_MEIPASS'):
# Running from PyInstaller bundle
bundle_dir = sys._MEIPASS
ffprobe_path = os.path.join(bundle_dir, "ffprobe.exe")
if os.path.exists(ffprobe_path):
return ffprobe_path
# Check current directory
ffprobe_path = os.path.join(os.getcwd(), "ffprobe.exe")
if os.path.exists(ffprobe_path):
return ffprobe_path
# Check system PATH
try:
subprocess.run(["ffprobe", "-version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
return "ffprobe"
except:
pass
return None