pcdoido2 commited on
Commit
79fbb3e
·
verified ·
1 Parent(s): 07e9b0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -50,7 +50,7 @@ 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 HARD (força reescrita completa)"""
54
  mime, _ = mimetypes.guess_type(file_path)
55
  if not mime or not mime.startswith("video"):
56
  return # não é vídeo
@@ -64,26 +64,32 @@ def randomize_video_metadata(file_path):
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(["isom,iso2", "iso2,mp41", "mp42,isom", "avc1,isom"]),
68
  "album": random_string(12),
69
  "artist": random_string(12)
70
  }
71
 
72
- # Reescreve completamente (reencode leve com libx264/aac)
73
  cmd = [
74
  "ffmpeg", "-y", "-i", file_path,
75
  "-c:v", "libx264", "-preset", "fast", "-crf", "23",
76
  "-c:a", "aac", "-b:a", "128k",
77
- "-movflags", "use_metadata_tags"
 
 
 
 
 
 
 
 
 
78
  ]
79
- for k, v in metadata.items():
80
- cmd.extend(["-metadata", f"{k}={v}"])
81
- cmd.append(temp_path)
82
 
83
  try:
84
  subprocess.run(cmd, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
85
  os.replace(temp_path, file_path)
86
- print(f"✅ Metadados HARD regravados em {file_path}")
87
  except Exception as e:
88
  print(f"⚠ Erro ao randomizar {file_path}: {e}")
89
 
 
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
 
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