Upload 11 files
Browse files- .gitattributes +1 -0
- ExtratorDeFrame.exe - Atalho.lnk +0 -0
- ExtratorDeFrames.exe +3 -0
- ExtratorDeFrames.exe - Atalho.lnk +0 -0
- ExtratorDeFrames.spec +45 -0
- extract_frames_gui.py +130 -0
- extract_last_frame_gui.spec +38 -0
.gitattributes
CHANGED
|
@@ -71,3 +71,4 @@ ComfyUI-Easy-Install-Windows/Helper-CEI-NEXT/ComfyUI-Easy-Install/python_embeded
|
|
| 71 |
ComfyUI-Easy-Install-Windows/Helper-CEI-NEXT/ComfyUI-Easy-Install/python_embeded_3.12/libs/python3.lib filter=lfs diff=lfs merge=lfs -text
|
| 72 |
ComfyUI-Easy-Install-Windows/Helper-CEI-NEXT/ComfyUI-Easy-Install/python_embeded_3.12/libs/python312.lib filter=lfs diff=lfs merge=lfs -text
|
| 73 |
ExtratorDeFrame.exe filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 71 |
ComfyUI-Easy-Install-Windows/Helper-CEI-NEXT/ComfyUI-Easy-Install/python_embeded_3.12/libs/python3.lib filter=lfs diff=lfs merge=lfs -text
|
| 72 |
ComfyUI-Easy-Install-Windows/Helper-CEI-NEXT/ComfyUI-Easy-Install/python_embeded_3.12/libs/python312.lib filter=lfs diff=lfs merge=lfs -text
|
| 73 |
ExtratorDeFrame.exe filter=lfs diff=lfs merge=lfs -text
|
| 74 |
+
ExtratorDeFrames.exe filter=lfs diff=lfs merge=lfs -text
|
ExtratorDeFrame.exe - Atalho.lnk
ADDED
|
Binary file (985 Bytes). View file
|
|
|
ExtratorDeFrames.exe
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:356b7d80dcdac8768ab68396dd94adefcbb62bb90c3c448a1528ae1d932c80b0
|
| 3 |
+
size 59926396
|
ExtratorDeFrames.exe - Atalho.lnk
ADDED
|
Binary file (990 Bytes). View file
|
|
|
ExtratorDeFrames.spec
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- mode: python ; coding: utf-8 -*-
|
| 2 |
+
from PyInstaller.utils.hooks import collect_all
|
| 3 |
+
|
| 4 |
+
datas = []
|
| 5 |
+
binaries = []
|
| 6 |
+
hiddenimports = ['tkinterdnd2']
|
| 7 |
+
tmp_ret = collect_all('tkinterdnd2')
|
| 8 |
+
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
a = Analysis(
|
| 12 |
+
['extract_frames_gui.py'],
|
| 13 |
+
pathex=[],
|
| 14 |
+
binaries=binaries,
|
| 15 |
+
datas=datas,
|
| 16 |
+
hiddenimports=hiddenimports,
|
| 17 |
+
hookspath=[],
|
| 18 |
+
hooksconfig={},
|
| 19 |
+
runtime_hooks=[],
|
| 20 |
+
excludes=[],
|
| 21 |
+
noarchive=False,
|
| 22 |
+
optimize=0,
|
| 23 |
+
)
|
| 24 |
+
pyz = PYZ(a.pure)
|
| 25 |
+
|
| 26 |
+
exe = EXE(
|
| 27 |
+
pyz,
|
| 28 |
+
a.scripts,
|
| 29 |
+
a.binaries,
|
| 30 |
+
a.datas,
|
| 31 |
+
[],
|
| 32 |
+
name='ExtratorDeFrames',
|
| 33 |
+
debug=False,
|
| 34 |
+
bootloader_ignore_signals=False,
|
| 35 |
+
strip=False,
|
| 36 |
+
upx=True,
|
| 37 |
+
upx_exclude=[],
|
| 38 |
+
runtime_tmpdir=None,
|
| 39 |
+
console=False,
|
| 40 |
+
disable_windowed_traceback=False,
|
| 41 |
+
argv_emulation=False,
|
| 42 |
+
target_arch=None,
|
| 43 |
+
codesign_identity=None,
|
| 44 |
+
entitlements_file=None,
|
| 45 |
+
)
|
extract_frames_gui.py
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import cv2
|
| 3 |
+
import re
|
| 4 |
+
from tkinter import messagebox, Label, StringVar
|
| 5 |
+
from tkinter import ttk
|
| 6 |
+
from tkinterdnd2 import TkinterDnD, DND_FILES
|
| 7 |
+
|
| 8 |
+
def extract_frames(video_path, mode):
|
| 9 |
+
# Remove chavetas que o Windows por vezes coloca em caminhos com espaços
|
| 10 |
+
video_path = video_path.strip('{}').strip('"')
|
| 11 |
+
|
| 12 |
+
if not os.path.exists(video_path):
|
| 13 |
+
return False, f"O ficheiro não existe: {video_path}"
|
| 14 |
+
|
| 15 |
+
try:
|
| 16 |
+
cap = cv2.VideoCapture(video_path)
|
| 17 |
+
if not cap.isOpened():
|
| 18 |
+
return False, f"Não foi possível abrir o vídeo: {os.path.basename(video_path)}"
|
| 19 |
+
|
| 20 |
+
total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
|
| 21 |
+
if total_frames <= 0:
|
| 22 |
+
cap.release()
|
| 23 |
+
return False, "O vídeo parece não ter frames."
|
| 24 |
+
|
| 25 |
+
base_name, _ = os.path.splitext(video_path)
|
| 26 |
+
results = []
|
| 27 |
+
|
| 28 |
+
# Extrair Primeiro Frame
|
| 29 |
+
if mode in ["Primeiro", "Ambos"]:
|
| 30 |
+
cap.set(cv2.CAP_PROP_POS_FRAMES, 0)
|
| 31 |
+
success, frame = cap.read()
|
| 32 |
+
if success:
|
| 33 |
+
output_path = f"{base_name}-first-frame.jpg"
|
| 34 |
+
cv2.imwrite(output_path, frame)
|
| 35 |
+
results.append(output_path)
|
| 36 |
+
else:
|
| 37 |
+
cap.release()
|
| 38 |
+
return False, "Não foi possível ler o primeiro frame."
|
| 39 |
+
|
| 40 |
+
# Extrair Último Frame
|
| 41 |
+
if mode in ["Último", "Ambos"]:
|
| 42 |
+
cap.set(cv2.CAP_PROP_POS_FRAMES, total_frames - 1)
|
| 43 |
+
success, frame = cap.read()
|
| 44 |
+
if success:
|
| 45 |
+
output_path = f"{base_name}-last-frame.jpg"
|
| 46 |
+
cv2.imwrite(output_path, frame)
|
| 47 |
+
results.append(output_path)
|
| 48 |
+
else:
|
| 49 |
+
cap.release()
|
| 50 |
+
return False, "Não foi possível ler o último frame."
|
| 51 |
+
|
| 52 |
+
cap.release()
|
| 53 |
+
if results:
|
| 54 |
+
return True, results
|
| 55 |
+
else:
|
| 56 |
+
return False, "Nenhum frame foi extraído."
|
| 57 |
+
|
| 58 |
+
except Exception as e:
|
| 59 |
+
return False, str(e)
|
| 60 |
+
|
| 61 |
+
class App(TkinterDnD.Tk):
|
| 62 |
+
def __init__(self):
|
| 63 |
+
super().__init__()
|
| 64 |
+
self.title("Extrator de Frames (Primeiro/Último)")
|
| 65 |
+
self.geometry("450x350")
|
| 66 |
+
|
| 67 |
+
# Estilo simples
|
| 68 |
+
self.configure(bg='#f0f0f0')
|
| 69 |
+
|
| 70 |
+
# Frame para as opções no topo
|
| 71 |
+
self.options_frame = ttk.Frame(self, padding="10 10 10 0")
|
| 72 |
+
self.options_frame.pack(fill="x")
|
| 73 |
+
|
| 74 |
+
ttk.Label(self.options_frame, text="Modo de extração:").pack(side="left", padx=5)
|
| 75 |
+
|
| 76 |
+
self.mode_var = StringVar()
|
| 77 |
+
self.mode_combo = ttk.Combobox(
|
| 78 |
+
self.options_frame,
|
| 79 |
+
textvariable=self.mode_var,
|
| 80 |
+
values=["Primeiro", "Último", "Ambos"],
|
| 81 |
+
state="readonly"
|
| 82 |
+
)
|
| 83 |
+
self.mode_combo.current(2) # Default para "Ambos"
|
| 84 |
+
self.mode_combo.pack(side="left", padx=5, expand=True, fill="x")
|
| 85 |
+
|
| 86 |
+
# Zona de Drop
|
| 87 |
+
self.label = Label(
|
| 88 |
+
self,
|
| 89 |
+
text="Arraste o vídeo para aqui\n(MP4, AVI, MKV, etc.)",
|
| 90 |
+
padx=20, pady=20,
|
| 91 |
+
bg="white", relief="groove",
|
| 92 |
+
font=("Arial", 12),
|
| 93 |
+
cursor="hand2"
|
| 94 |
+
)
|
| 95 |
+
self.label.pack(expand=True, fill="both", padx=40, pady=20)
|
| 96 |
+
|
| 97 |
+
# Registar o Drop
|
| 98 |
+
self.label.drop_target_register(DND_FILES)
|
| 99 |
+
self.label.dnd_bind('<<Drop>>', self.handle_drop)
|
| 100 |
+
|
| 101 |
+
def handle_drop(self, event):
|
| 102 |
+
data = event.data
|
| 103 |
+
# Expressão regular para capturar caminhos entre chavetas ou caminhos sem espaços
|
| 104 |
+
files = re.findall(r'\{.*?\}|\S+', data)
|
| 105 |
+
|
| 106 |
+
mode = self.mode_var.get()
|
| 107 |
+
success_count = 0
|
| 108 |
+
error_msgs = []
|
| 109 |
+
|
| 110 |
+
for file_path in files:
|
| 111 |
+
file_path = file_path.strip('{}').strip('"')
|
| 112 |
+
success, result = extract_frames(file_path, mode)
|
| 113 |
+
if success:
|
| 114 |
+
success_count += 1
|
| 115 |
+
else:
|
| 116 |
+
error_msgs.append(f"{os.path.basename(file_path)}: {result}")
|
| 117 |
+
|
| 118 |
+
if success_count > 0:
|
| 119 |
+
self.label.config(bg="#d4edda", text=f"Sucesso! {success_count} ficheiro(s) processado(s).")
|
| 120 |
+
self.after(3000, self.reset_label)
|
| 121 |
+
|
| 122 |
+
if error_msgs:
|
| 123 |
+
messagebox.showerror("Erro", "\n".join(error_msgs))
|
| 124 |
+
|
| 125 |
+
def reset_label(self):
|
| 126 |
+
self.label.config(bg="white", text="Arraste o vídeo para aqui\n(MP4, AVI, MKV, etc.)")
|
| 127 |
+
|
| 128 |
+
if __name__ == "__main__":
|
| 129 |
+
app = App()
|
| 130 |
+
app.mainloop()
|
extract_last_frame_gui.spec
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- mode: python ; coding: utf-8 -*-
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
a = Analysis(
|
| 5 |
+
['C:\\Users\\luisf\\extract_last_frame_gui.py'],
|
| 6 |
+
pathex=[],
|
| 7 |
+
binaries=[],
|
| 8 |
+
datas=[],
|
| 9 |
+
hiddenimports=[],
|
| 10 |
+
hookspath=[],
|
| 11 |
+
hooksconfig={},
|
| 12 |
+
runtime_hooks=[],
|
| 13 |
+
excludes=[],
|
| 14 |
+
noarchive=False,
|
| 15 |
+
optimize=0,
|
| 16 |
+
)
|
| 17 |
+
pyz = PYZ(a.pure)
|
| 18 |
+
|
| 19 |
+
exe = EXE(
|
| 20 |
+
pyz,
|
| 21 |
+
a.scripts,
|
| 22 |
+
a.binaries,
|
| 23 |
+
a.datas,
|
| 24 |
+
[],
|
| 25 |
+
name='extract_last_frame_gui',
|
| 26 |
+
debug=False,
|
| 27 |
+
bootloader_ignore_signals=False,
|
| 28 |
+
strip=False,
|
| 29 |
+
upx=False,
|
| 30 |
+
upx_exclude=[],
|
| 31 |
+
runtime_tmpdir=None,
|
| 32 |
+
console=True,
|
| 33 |
+
disable_windowed_traceback=False,
|
| 34 |
+
argv_emulation=False,
|
| 35 |
+
target_arch=None,
|
| 36 |
+
codesign_identity=None,
|
| 37 |
+
entitlements_file=None,
|
| 38 |
+
)
|