feat: core/waveform — peak reduction + ffmpeg region decode
This commit is contained in:
@@ -540,3 +540,29 @@ def test_audio_extract_ltx2_duration():
|
||||
duration=frames / fps)
|
||||
assert "-t" in cmd
|
||||
assert cmd[cmd.index("-t") + 1] == str(frames / fps)
|
||||
|
||||
|
||||
# --- waveform peak reduction + region decode ---
|
||||
|
||||
def test_peaks_downsamples_to_bucket_count():
|
||||
from core.waveform import peaks
|
||||
import numpy as np
|
||||
samples = np.sin(np.linspace(0, 100, 10000)).astype("float32")
|
||||
p = peaks(samples, buckets=64)
|
||||
assert len(p) == 64
|
||||
assert all(0.0 <= v <= 1.0 for v in p)
|
||||
|
||||
|
||||
def test_peaks_empty_returns_zeros():
|
||||
from core.waveform import peaks
|
||||
assert peaks(None, buckets=16) == [0.0] * 16
|
||||
import numpy as np
|
||||
assert peaks(np.zeros(0, dtype="float32"), buckets=8) == [0.0] * 8
|
||||
|
||||
|
||||
def test_load_region_samples_bad_path_returns_empty():
|
||||
from core.waveform import load_region_samples
|
||||
import numpy as np
|
||||
out = load_region_samples("/no/such/file.mp4", 0.0, 1.0)
|
||||
assert isinstance(out, np.ndarray)
|
||||
assert out.size == 0
|
||||
|
||||
Reference in New Issue
Block a user