upgrade VideoCompress
This commit is contained in:
@ -7,6 +7,5 @@
|
|||||||
".mp4",
|
".mp4",
|
||||||
".mkv"
|
".mkv"
|
||||||
],
|
],
|
||||||
"extra": [],
|
"extra": []
|
||||||
"train": false
|
|
||||||
}
|
}
|
||||||
@ -15,7 +15,6 @@ import queue
|
|||||||
import psutil
|
import psutil
|
||||||
|
|
||||||
root = None
|
root = None
|
||||||
CFG_FILE = Path(sys.path[0])/"config.json"
|
|
||||||
CFG = {
|
CFG = {
|
||||||
"save_to": "single",
|
"save_to": "single",
|
||||||
"crf":"18",
|
"crf":"18",
|
||||||
@ -45,6 +44,13 @@ cpu_monitor_lock = threading.Lock()
|
|||||||
current_instances = 0
|
current_instances = 0
|
||||||
instance_lock = threading.Lock()
|
instance_lock = threading.Lock()
|
||||||
|
|
||||||
|
def get_config_path() -> Path:
|
||||||
|
"""获取配置文件路径"""
|
||||||
|
if os.environ.get("INSTALL", "0") == "1":
|
||||||
|
return Path(os.getenv("APPDATA", "C:/")) / "VideoCompress" / "config.json"
|
||||||
|
else:
|
||||||
|
return Path("config.json").resolve()
|
||||||
|
|
||||||
def get_cmd(video_path,output_file):
|
def get_cmd(video_path,output_file):
|
||||||
if CFG["manual"] is not None:
|
if CFG["manual"] is not None:
|
||||||
command=[
|
command=[
|
||||||
@ -296,10 +302,9 @@ def process_video(video_path: Path, compress_dir:Optional[Path]=None, update_fun
|
|||||||
def traverse_directory(root_dir: Path):
|
def traverse_directory(root_dir: Path):
|
||||||
global current_instances
|
global current_instances
|
||||||
video_extensions = set(CFG["video_ext"])
|
video_extensions = set(CFG["video_ext"])
|
||||||
sm=None
|
|
||||||
# 获取视频文件列表和帧数信息
|
# 获取视频文件列表和帧数信息
|
||||||
video_files = []
|
video_files = []
|
||||||
que = list(root_dir.glob("*"))
|
que = [root_dir]
|
||||||
while que:
|
while que:
|
||||||
d = que.pop()
|
d = que.pop()
|
||||||
for file in d.glob("*"):
|
for file in d.glob("*"):
|
||||||
@ -535,10 +540,10 @@ def main(_root = None):
|
|||||||
logging.info("-------------------------------")
|
logging.info("-------------------------------")
|
||||||
logging.info(datetime.now().strftime('Video Compress started at %Y/%m/%d %H:%M'))
|
logging.info(datetime.now().strftime('Video Compress started at %Y/%m/%d %H:%M'))
|
||||||
|
|
||||||
if CFG_FILE.exists():
|
if get_config_path().exists():
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
cfg:dict = json.loads(CFG_FILE.read_text())
|
cfg:dict = json.loads(get_config_path().read_text())
|
||||||
CFG.update(cfg)
|
CFG.update(cfg)
|
||||||
except KeyboardInterrupt as e:raise e
|
except KeyboardInterrupt as e:raise e
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user