pcdoido2 commited on
Commit
0004fa7
·
verified ·
1 Parent(s): 79fbb3e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -24
app.py CHANGED
@@ -50,46 +50,48 @@ def random_string(n=12):
50
  return ''.join(random.choices(string.ascii_letters + string.digits, k=n))
51
 
52
  def randomize_video_metadata(file_path):
53
- """Randomiza metadados de vídeos de forma FULL HARD"""
54
  mime, _ = mimetypes.guess_type(file_path)
55
  if not mime or not mime.startswith("video"):
56
- return # não é vídeo
57
 
58
  temp_path = file_path + ".tmp"
59
 
60
- # Metadados aleatórios
61
- metadata = {
62
- "title": random_string(16),
63
- "comment": random_string(20),
64
- "description": random_string(20),
65
- "encoder": random_string(12),
66
- "major_brand": random.choice(["isom", "iso2", "mp41", "mp42", "avc1"]),
67
- "compatible_brands": random.choice(["mp42,isom", "isom,avc1", "iso2,mp41"]),
68
- "album": random_string(12),
69
- "artist": random_string(12)
70
- }
 
 
71
 
72
- # ffmpeg reencode leve (garante sobrescrita completa de atoms e tags)
73
  cmd = [
74
  "ffmpeg", "-y", "-i", file_path,
 
75
  "-c:v", "libx264", "-preset", "fast", "-crf", "23",
76
  "-c:a", "aac", "-b:a", "128k",
77
- "-brand", metadata["major_brand"],
78
- "-metadata", f"compatible_brands={metadata['compatible_brands']}",
79
- "-metadata", f"encoder={metadata['encoder']}",
80
- "-metadata", f"title={metadata['title']}",
81
- "-metadata", f"comment={metadata['comment']}",
82
- "-metadata", f"description={metadata['description']}",
83
- "-metadata", f"artist={metadata['artist']}",
84
- "-metadata", f"album={metadata['album']}",
85
- "-movflags", "use_metadata_tags",
86
  temp_path
87
  ]
88
 
89
  try:
90
  subprocess.run(cmd, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
91
  os.replace(temp_path, file_path)
92
- print(f"✅ Metadados FULL HARD aplicados em {file_path}")
93
  except Exception as e:
94
  print(f"⚠ Erro ao randomizar {file_path}: {e}")
95
 
 
50
  return ''.join(random.choices(string.ascii_letters + string.digits, k=n))
51
 
52
  def randomize_video_metadata(file_path):
53
+ """FULL HARD: limpa tudo e reinsere metadados randômicos"""
54
  mime, _ = mimetypes.guess_type(file_path)
55
  if not mime or not mime.startswith("video"):
56
+ return
57
 
58
  temp_path = file_path + ".tmp"
59
 
60
+ # strings randômicas
61
+ rand_enc = random_string(8)
62
+ rand_title = random_string(12)
63
+ rand_comment = random_string(12)
64
+ rand_desc = random_string(12)
65
+ rand_artist = random_string(10)
66
+ rand_album = random_string(10)
67
+ rand_brand = random.choice(["mp42", "iso2", "isom", "avc1"])
68
+ rand_compat = random.choice([
69
+ "mp42,isom,avc1",
70
+ "isom,avc1,mp41",
71
+ "iso2,mp42,isom"
72
+ ])
73
 
 
74
  cmd = [
75
  "ffmpeg", "-y", "-i", file_path,
76
+ "-map_metadata", "-1", # ⚡ limpa TODOS os metadados originais
77
  "-c:v", "libx264", "-preset", "fast", "-crf", "23",
78
  "-c:a", "aac", "-b:a", "128k",
79
+ "-movflags", "use_metadata_tags+faststart",
80
+ "-brand", rand_brand,
81
+ "-metadata", f"compatible_brands={rand_compat}",
82
+ "-metadata:s:v", f"encoder={rand_enc}",
83
+ "-metadata", f"title={rand_title}",
84
+ "-metadata", f"comment={rand_comment}",
85
+ "-metadata", f"description={rand_desc}",
86
+ "-metadata", f"artist={rand_artist}",
87
+ "-metadata", f"album={rand_album}",
88
  temp_path
89
  ]
90
 
91
  try:
92
  subprocess.run(cmd, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
93
  os.replace(temp_path, file_path)
94
+ print(f"✅ FULL HARD METADATA aplicado em {file_path}")
95
  except Exception as e:
96
  print(f"⚠ Erro ao randomizar {file_path}: {e}")
97