|
3 | 3 | from tkinter import filedialog, messagebox |
4 | 4 | from pydub import AudioSegment |
5 | 5 |
|
| 6 | +# 无ffmpeg的打包指令:pyinstaller --onefile --windowed Main.py |
| 7 | +# 包含ffmpeg打包指令:pyinstaller --onedir --add-binary="C:/Users/Apermesa/Downloads/Compressed/ffmpeg-2024-12-19-git-494c961379-essentials_build/bin/ffmpeg.exe;." --windowed Main.py |
| 8 | +# 若要打包无ffmpeg版本,则删除下面这两行 |
| 9 | +ffmpeg_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "ffmpeg.exe") |
| 10 | +AudioSegment.converter = ffmpeg_path |
| 11 | + |
6 | 12 | def generate_empty_audio(output_file, file_name): |
7 | 13 | """ |
8 | 14 | 生成一个无声的短音频文件,包含标准 MP3 元数据 |
@@ -31,7 +37,8 @@ def embed_file_in_audio(file_path): |
31 | 37 | if not generate_empty_audio(output_audio_file, file_name_with_extension): |
32 | 38 | return |
33 | 39 |
|
34 | | - output_file = os.path.join(os.path.dirname(file_path), os.path.splitext(file_name_with_extension)[0] + " (embedded).mp3") |
| 40 | + output_file = os.path.join(os.path.dirname(file_path), |
| 41 | + os.path.splitext(file_name_with_extension)[0] + " (embedded).mp3") |
35 | 42 | try: |
36 | 43 | with open(output_audio_file, "rb") as audio, open(file_path, "rb") as file: |
37 | 44 | with open(output_file, "wb") as output: |
@@ -95,16 +102,21 @@ def extract_action(): |
95 | 102 |
|
96 | 103 | # 创建主界面 |
97 | 104 | root = tk.Tk() |
98 | | -root.title("文件嵌入与提取工具") |
99 | | -root.geometry("400x200") |
| 105 | +root.title("文件伪装音频工具") |
| 106 | +root.geometry("300x220") |
| 107 | +root.resizable(False, False) |
100 | 108 |
|
101 | 109 | # 嵌入按钮 |
102 | | -embed_button = tk.Button(root, text="嵌入文件到音频", command=embed_action, height=2, width=20) |
| 110 | +embed_button = tk.Button(root, text="嵌入", command=embed_action, height=2, width=20) |
103 | 111 | embed_button.pack(pady=20) |
104 | 112 |
|
105 | 113 | # 提取按钮 |
106 | | -extract_button = tk.Button(root, text="提取文件从音频", command=extract_action, height=2, width=20) |
| 114 | +extract_button = tk.Button(root, text="提取", command=extract_action, height=2, width=20) |
107 | 115 | extract_button.pack(pady=20) |
108 | 116 |
|
| 117 | +# 作者标签 |
| 118 | +author_label = tk.Label(root, text="作者:Apermesa", font=("Arial", 10)) |
| 119 | +author_label.pack(side="bottom", pady=10) |
| 120 | + |
109 | 121 | # 运行主循环 |
110 | 122 | root.mainloop() |
0 commit comments