Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -20,15 +20,15 @@ def guardar_frame(frame, index, temp_dir):
|
|
20 |
def procesar_video(video_path):
|
21 |
try:
|
22 |
original_name = os.path.basename(video_path)
|
23 |
-
allowed_extensions = ('.mp4', '.avi', '.mov', '.mkv')
|
24 |
-
if not original_name.lower().endswith(allowed_extensions):
|
25 |
-
raise gr.Error("Solo se permiten archivos de video (mp4, avi, mov, mkv)")
|
26 |
|
27 |
timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
28 |
temp_dir = f"temp_{datetime.now().strftime('%Y%m%d%H%M%S')}"
|
29 |
os.makedirs(temp_dir, exist_ok=True)
|
30 |
|
31 |
cap = cv2.VideoCapture(video_path)
|
|
|
|
|
|
|
32 |
index = 0
|
33 |
futures = []
|
34 |
with ThreadPoolExecutor(max_workers=4) as executor:
|
@@ -44,7 +44,7 @@ def procesar_video(video_path):
|
|
44 |
frame_count = len(frame_paths)
|
45 |
|
46 |
if frame_count == 0:
|
47 |
-
raise gr.Error("No se pudieron extraer fotogramas del video")
|
48 |
|
49 |
n_seleccion = 4
|
50 |
step = max(1, frame_count // (n_seleccion + 1))
|
@@ -93,14 +93,14 @@ def procesar_video(video_path):
|
|
93 |
video_hash = hashlib.md5(f.read()).hexdigest()
|
94 |
|
95 |
chain_content = (
|
96 |
-
"=== CADENA DE CUSTODIA DIGITAL
|
97 |
-
f"• Archivo original: {original_name}
|
98 |
-
f"• Fecha de procesamiento: {timestamp}
|
99 |
-
f"• Fotogramas totales: {frame_count}
|
100 |
-
f"• Hash MD5 video: {video_hash}
|
101 |
-
f"• Fotogramas muestra: {', '.join([f'#{i+1}' for i in selected_indices])}
|
102 |
-
"Este documento certifica la integridad del proceso de extracción
|
103 |
-
"Sistema Certificado por Peritos Forenses Digitales de Guatemala.
|
104 |
"www.forensedigital.gt"
|
105 |
)
|
106 |
zipf.writestr("00_CADENA_CUSTODIA.txt", chain_content)
|
@@ -121,7 +121,7 @@ def limpiar_cache():
|
|
121 |
|
122 |
with gr.Blocks(title="Extractor Forense de Fotogramas") as demo:
|
123 |
gr.Markdown("# 📷 Extractor Forense de Fotogramas de Videos")
|
124 |
-
gr.Markdown("
|
125 |
gr.Markdown("Desarrollado por José R. Leonett para el Grupo de Peritos Forenses Digitales de Guatemala - [www.forensedigital.gt](https://www.forensedigital.gt)")
|
126 |
|
127 |
with gr.Row():
|
|
|
20 |
def procesar_video(video_path):
|
21 |
try:
|
22 |
original_name = os.path.basename(video_path)
|
|
|
|
|
|
|
23 |
|
24 |
timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
25 |
temp_dir = f"temp_{datetime.now().strftime('%Y%m%d%H%M%S')}"
|
26 |
os.makedirs(temp_dir, exist_ok=True)
|
27 |
|
28 |
cap = cv2.VideoCapture(video_path)
|
29 |
+
if not cap.isOpened():
|
30 |
+
raise gr.Error("No se pudo abrir el archivo de video. Formato no soportado o archivo dañado.")
|
31 |
+
|
32 |
index = 0
|
33 |
futures = []
|
34 |
with ThreadPoolExecutor(max_workers=4) as executor:
|
|
|
44 |
frame_count = len(frame_paths)
|
45 |
|
46 |
if frame_count == 0:
|
47 |
+
raise gr.Error("No se pudieron extraer fotogramas del video.")
|
48 |
|
49 |
n_seleccion = 4
|
50 |
step = max(1, frame_count // (n_seleccion + 1))
|
|
|
93 |
video_hash = hashlib.md5(f.read()).hexdigest()
|
94 |
|
95 |
chain_content = (
|
96 |
+
"=== CADENA DE CUSTODIA DIGITAL ===\\r\\n\\r\\n"
|
97 |
+
f"• Archivo original: {original_name}\\r\\n"
|
98 |
+
f"• Fecha de procesamiento: {timestamp}\\r\\n"
|
99 |
+
f"• Fotogramas totales: {frame_count}\\r\\n"
|
100 |
+
f"• Hash MD5 video: {video_hash}\\r\\n"
|
101 |
+
f"• Fotogramas muestra: {', '.join([f'#{i+1}' for i in selected_indices])}\\r\\n\\r\\n"
|
102 |
+
"Este documento certifica la integridad del proceso de extracción.\\n"
|
103 |
+
"Sistema Certificado por Peritos Forenses Digitales de Guatemala. \\n"
|
104 |
"www.forensedigital.gt"
|
105 |
)
|
106 |
zipf.writestr("00_CADENA_CUSTODIA.txt", chain_content)
|
|
|
121 |
|
122 |
with gr.Blocks(title="Extractor Forense de Fotogramas") as demo:
|
123 |
gr.Markdown("# 📷 Extractor Forense de Fotogramas de Videos")
|
124 |
+
gr.Markdown("**Herramienta certificada para extracción forense de fotogramas de videos** \n(No se guarda ninguna información).")
|
125 |
gr.Markdown("Desarrollado por José R. Leonett para el Grupo de Peritos Forenses Digitales de Guatemala - [www.forensedigital.gt](https://www.forensedigital.gt)")
|
126 |
|
127 |
with gr.Row():
|