main
oscar 3 months ago
parent 350eea60a3
commit 29938c3cbd

@ -2,6 +2,7 @@ from flask import Flask, render_template, request, redirect, url_for
from funcs import process_videos, group_videos, match_data_to_video_fast, get_all_videos, get_all_data
from config import connect_redis
import json, os, time, math, subprocess
from tqdm import tqdm
# -------------------- CONFIG -------------------- #
app = Flask(__name__)
@ -24,14 +25,15 @@ DATA_DIRS = [
os.makedirs(THUMB_DIR, exist_ok=True)
# -------------------- UTILS -------------------- #
# -------------------- UTILS -------------------- #
def generate_thumbnail(video_path, thumb_path):
if not os.path.exists(thumb_path):
cmd = [
"ffmpeg", "-y", "-i", video_path, "-ss", "00:00:05.000",
"-vframes", "1", thumb_path
]
subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if os.path.exists(thumb_path):
return
cmd = [
"ffmpeg", "-y", "-i", video_path, "-ss", "00:00:05.000",
"-vframes", "1", thumb_path
]
subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
def load_video_data():
videos = []
@ -62,12 +64,14 @@ def compute_analytics(video_data):
}
avg_sizes[key] = avg_size_gb
for v in vids:
video_id = os.path.basename(v['filepath'])
thumb_path = os.path.join(THUMB_DIR, f"{video_id}.jpg")
generate_thumbnail(v['filepath'], thumb_path)
v['thumbnail'] = thumb_path
video_map[key] = vids
with tqdm(vids, desc=f"Generating thumbnails for {username} ({platform})") as pbar:
for v in vids:
pbar.update(1)
video_id = os.path.basename(v['filepath']).split('.')[0]
thumb_path = os.path.join(THUMB_DIR, f"{video_id}.jpg")
generate_thumbnail(v['filepath'], thumb_path)
v['thumbnail'] = thumb_path
video_map[key] = vids
return storage_usage, avg_sizes, video_map
def refresh_data():

Loading…
Cancel
Save