-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.py
More file actions
64 lines (46 loc) · 1.75 KB
/
main.py
File metadata and controls
64 lines (46 loc) · 1.75 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import sys
import os
import ctypes
from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import QIcon
import logging
from os.path import dirname, abspath
from utils.path_utils import get_ffmpeg_path
project_root = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, project_root)
from ui.main_window import VideoUnicApp
from utils.constants import APP_NAME, APP_VERSION, FFMPEG_EXE_PATH
def set_app_user_model_id(app_id):
if sys.platform == "win32":
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(app_id)
def main():
log_file_path = os.path.join(project_root, "crash_log.log")
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] - %(message)s",
handlers=[
logging.FileHandler(log_file_path, mode="w", encoding="utf-8"),
logging.StreamHandler(sys.stdout)
]
)
logging.info("Application started.")
if sys.platform.startswith("win"):
try:
os.system("chcp 65001")
os.environ["PYTHONIOENCODING"] = "utf-8"
except Exception as e:
logging.warning("Warning: Failed to set console encoding: " + str(e))
app = QApplication(sys.argv)
app.setApplicationName(APP_NAME)
app.setApplicationVersion(APP_VERSION)
myappid = f"mycompany.{APP_NAME}.{APP_VERSION}"
set_app_user_model_id(myappid)
ffpmeg_path = get_ffmpeg_path()
if sys.platform.startswith("win") and not os.path.exists(ffpmeg_path):
logging.error(f"Error: ffmpeg.exe not found at {FFMPEG_EXE_PATH}")
logging.error("Please ensure FFmpeg is in the specified path or in your system's PATH.")
w = VideoUnicApp()
w.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()