Verify unseen music stress inputs against production decoding
This commit is contained in:
1 parent
d27be302c8
commit
cbf07b0575
4 files changed
+90
-28
No files matched your search
@@ -4,6 +4,7 @@ import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import struct
|
||||
import urllib.request
|
||||
|
||||
|
||||
@@ -23,11 +24,13 @@ def probe(path, ffprobe):
|
||||
return tags
|
||||
|
||||
|
||||
def pcm(path, ffmpeg):
|
||||
data = execute([str(ffmpeg), "-v", "error", "-nostdin", "-threads", "1", "-i", str(path), "-t", "30", "-ac", "1", "-ar", "16000", "-f", "f32le", "pipe:1"])
|
||||
if not data or len(data) > 480000 * 4 or len(data) % 4:
|
||||
def pcm(path, ffmpeg, ffprobe):
|
||||
metadata = json.loads(execute([str(ffprobe), "-v", "error", "-show_format", "-of", "json", str(path)]))
|
||||
duration_ms = min(30000, int(float(metadata["format"]["duration"]) * 1000 + 0.5))
|
||||
data = execute([str(ffmpeg), "-v", "error", "-nostdin", "-threads", "1", "-ss", "0.000", "-t", f"{duration_ms / 1000:.3f}", "-i", str(path), "-af", f"aresample=16000,atrim=end_sample={duration_ms * 16},asetpts=PTS-STARTPTS", "-ac", "1", "-ar", "16000", "-threads", "1", "-f", "s16le", "pipe:1"])
|
||||
if not data or len(data) > 480000 * 2 or len(data) % 2:
|
||||
raise ValueError("Invalid bounded PCM")
|
||||
return sha(data)
|
||||
return sha(b"".join(struct.pack("<f", value[0] / 32768) for value in struct.iter_unpack("<h", data)))
|
||||
|
||||
|
||||
def main():
|
||||
@@ -74,7 +77,7 @@ def main():
|
||||
command.extend(["-metadata", f"{key}={tags[key]}"])
|
||||
command.append(str(path))
|
||||
execute(command)
|
||||
pcm_hash = pcm(path, args.ffmpeg)
|
||||
pcm_hash = pcm(path, args.ffmpeg, args.ffprobe)
|
||||
if original_pcm is None:
|
||||
original_pcm = pcm_hash
|
||||
if pcm_hash != original_pcm:
|
||||
|
||||
Reference in new issue
Block a user