修复pyinstaller下ffmeg失效问题

This commit is contained in:
tech-shrimp 2024-03-29 15:32:44 +08:00
parent 20e21b3d3e
commit 408f5987d0
2 changed files with 5 additions and 6 deletions

View File

@ -44,7 +44,7 @@ class VideoDecrypter:
# 这是到_internal文件夹
resource_dir = getattr(sys, '_MEIPASS')
# 获取_internal上一级文件夹再拼接
return os.path.join(resource_dir, 'output', dir_name, 'videos', f'{md5}_{duration}.mp4')
return os.path.join(os.path.dirname(resource_dir), 'output', dir_name, 'videos', f'{md5}_{duration}.mp4')
else:
return os.path.join(os.getcwd(), 'output', dir_name, 'videos', f'{md5}_{duration}.mp4')
@ -117,8 +117,10 @@ class VideoDecrypter:
input_path = str(file.resolve())
ffmpeg_path = self.get_ffmpeg_path()
output_path = self.get_output_path(dir_name, md5, duration)
print("ffmpeg_path: " + str(ffmpeg_path))
if os.path.exists(ffmpeg_path):
cmd = f'''"{ffmpeg_path}" -loglevel quiet -i "{input_path}" -c:v libx264 "{output_path}"'''
print("ffmpeg_path cmd:" + cmd)
subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
else:
shutil.copy(file.resolve(), f"output/{dir_name}/videos/{md5}_{duration}.mp4")

View File

@ -1,14 +1,11 @@
import os
import threading
import tkinter
import tkinter.font
import tkinter.ttk
from datetime import datetime, timedelta
from pathlib import Path
from typing import Optional
from time import sleep
import tkcalendar
from pywxdump import read_info
from decrypter.db_decrypt import DatabaseDecrypter
from decrypter.video_decrypt import VideoDecrypter
from gui.auto_scroll_guide import AutoScrollGuide
@ -82,13 +79,13 @@ class Gui:
self.waiting_label.config(text="微信已登录")
self.auto_scroll_button_text = tkinter.StringVar()
self.auto_scroll_button_text.set("读取全部朋友")
self.auto_scroll_button_text.set("自动浏览全部朋友圈")
self.auto_scroll_button = tkinter.ttk.Button(self.root, textvariable=self.auto_scroll_button_text,
command=self.open_auto_scroll_guide)
self.auto_scroll_button.place(relx=0.35, rely=0.15, anchor='center')
self.auto_scroll_button_single_text = tkinter.StringVar()
self.auto_scroll_button_single_text.set("读取单个朋友")
self.auto_scroll_button_single_text.set("自动浏览单个朋友")
self.auto_scroll_button_single = tkinter.ttk.Button(self.root, textvariable=self.auto_scroll_button_single_text,
command=self.switch_auto_scroll_single)
self.auto_scroll_button_single.place(relx=0.655, rely=0.15, anchor='center')