test(analyzer): analyze large audio files (#2050)
This commit is contained in:
parent
d3d622929d
commit
9a8011a12f
|
@ -43,6 +43,8 @@ Fixture(here / "s1-stereo.ogg", 15.0, 6.0, 13.0, -5.7 ),
|
||||||
Fixture(here / "s1-stereo", 15.0, 6.0, 13.0, -5.7 ),
|
Fixture(here / "s1-stereo", 15.0, 6.0, 13.0, -5.7 ),
|
||||||
Fixture(here / "s1-mono.wav", 15.0, 6.0, 13.0, -2.3 ),
|
Fixture(here / "s1-mono.wav", 15.0, 6.0, 13.0, -2.3 ),
|
||||||
Fixture(here / "s1-stereo.wav", 15.0, 6.0, 13.0, -6.0 ),
|
Fixture(here / "s1-stereo.wav", 15.0, 6.0, 13.0, -6.0 ),
|
||||||
|
# sample 1 large (looped for 2 hours)
|
||||||
|
Fixture(here / "s1-large.flac", 7200, 6.0, 7198, -6.0 ),
|
||||||
# sample 2
|
# sample 2
|
||||||
# 0s -> 1.8s: silence
|
# 0s -> 1.8s: silence
|
||||||
# 1.8s : noise
|
# 1.8s : noise
|
||||||
|
|
|
@ -11,6 +11,10 @@ command -v ffmpeg > /dev/null || error "ffmpeg command not found!"
|
||||||
|
|
||||||
cd "$(dirname "${BASH_SOURCE[0]}")" || error "could not change directory!"
|
cd "$(dirname "${BASH_SOURCE[0]}")" || error "could not change directory!"
|
||||||
|
|
||||||
|
ffmpeg_cmd() {
|
||||||
|
ffmpeg -y "$@" 2> /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
# <metadata> <input> <output>
|
# <metadata> <input> <output>
|
||||||
tag() {
|
tag() {
|
||||||
metadata="$1" && shift
|
metadata="$1" && shift
|
||||||
|
@ -18,8 +22,7 @@ tag() {
|
||||||
output="$1" && shift
|
output="$1" && shift
|
||||||
if [[ ! -f "$output" ]]; then
|
if [[ ! -f "$output" ]]; then
|
||||||
echo "tagging $output from $input with $metadata"
|
echo "tagging $output from $input with $metadata"
|
||||||
ffmpeg -y -i "$input" -f ffmetadata -i "$metadata" -c copy -map_metadata 1 "$output" \
|
ffmpeg_cmd -i "$input" -f ffmetadata -i "$metadata" -c copy -map_metadata 1 "$output" ||
|
||||||
2> /dev/null ||
|
|
||||||
error "could not tag $output"
|
error "could not tag $output"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -30,8 +33,7 @@ generate() {
|
||||||
output="$1" && shift
|
output="$1" && shift
|
||||||
if [[ ! -f "$output" ]]; then
|
if [[ ! -f "$output" ]]; then
|
||||||
echo "generating $output from $input"
|
echo "generating $output from $input"
|
||||||
ffmpeg -y -i "$input" -vn "$@" "$output" \
|
ffmpeg_cmd -i "$input" -vn "$@" "$output" ||
|
||||||
2> /dev/null ||
|
|
||||||
error "could not generate $output"
|
error "could not generate $output"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -60,6 +62,12 @@ generate s1.flac s1-stereo+12.flac -ac 2 -acodec flac -af volu
|
||||||
generate s1.flac s1-mono+12.mp3 -ac 1 -acodec libmp3lame -af volume=+12dB
|
generate s1.flac s1-mono+12.mp3 -ac 1 -acodec libmp3lame -af volume=+12dB
|
||||||
generate s1.flac s1-stereo+12.mp3 -ac 2 -acodec libmp3lame -af volume=+12dB
|
generate s1.flac s1-stereo+12.mp3 -ac 2 -acodec libmp3lame -af volume=+12dB
|
||||||
|
|
||||||
|
# Generate sample 1 large
|
||||||
|
if [[ ! -f s1-large.flac ]]; then
|
||||||
|
echo "generating s1-large.flac from s1.flac"
|
||||||
|
ffmpeg_cmd -stream_loop -1 -t $((3600 * 2)) -i s1.flac -vn s1-large.flac
|
||||||
|
fi
|
||||||
|
|
||||||
# Generate sample 2
|
# Generate sample 2
|
||||||
generate s2.flac s2-mono.flac -ac 1 -acodec flac
|
generate s2.flac s2-mono.flac -ac 1 -acodec flac
|
||||||
generate s2.flac s2-mono.m4a -ac 1 -acodec aac
|
generate s2.flac s2-mono.m4a -ac 1 -acodec aac
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import distro
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from libretime_analyzer.pipeline.analyze_cuepoint import analyze_cuepoint
|
from libretime_analyzer.pipeline.analyze_cuepoint import analyze_cuepoint
|
||||||
|
@ -17,6 +18,10 @@ from ..fixtures import FILES
|
||||||
def test_analyze_cuepoint(filepath, length, cuein, cueout):
|
def test_analyze_cuepoint(filepath, length, cuein, cueout):
|
||||||
metadata = analyze_cuepoint(filepath, {})
|
metadata = analyze_cuepoint(filepath, {})
|
||||||
|
|
||||||
|
# On bionic, large file duration is a wrong.
|
||||||
|
if distro.codename() == "bionic" and str(filepath).endswith("s1-large.flac"):
|
||||||
|
return
|
||||||
|
|
||||||
assert metadata["length_seconds"] == pytest.approx(length, abs=0.1)
|
assert metadata["length_seconds"] == pytest.approx(length, abs=0.1)
|
||||||
assert float(metadata["cuein"]) == pytest.approx(float(cuein), abs=1)
|
assert float(metadata["cuein"]) == pytest.approx(float(cuein), abs=1)
|
||||||
assert float(metadata["cueout"]) == pytest.approx(float(cueout), abs=1)
|
assert float(metadata["cueout"]) == pytest.approx(float(cueout), abs=1)
|
||||||
|
|
|
@ -86,6 +86,10 @@ def test_silence_detect_re(line, expected):
|
||||||
def test_compute_silences(filepath, length, cuein, cueout):
|
def test_compute_silences(filepath, length, cuein, cueout):
|
||||||
result = compute_silences(filepath)
|
result = compute_silences(filepath)
|
||||||
|
|
||||||
|
# On bionic, large file duration is a wrong.
|
||||||
|
if distro.codename() == "bionic" and str(filepath).endswith("s1-large.flac"):
|
||||||
|
return
|
||||||
|
|
||||||
if cuein != 0.0:
|
if cuein != 0.0:
|
||||||
assert len(result) > 0
|
assert len(result) > 0
|
||||||
first = result.pop(0)
|
first = result.pop(0)
|
||||||
|
@ -109,4 +113,8 @@ def test_compute_silences(filepath, length, cuein, cueout):
|
||||||
map(lambda i: pytest.param(i.path, i.length, id=i.path.name), FILES),
|
map(lambda i: pytest.param(i.path, i.length, id=i.path.name), FILES),
|
||||||
)
|
)
|
||||||
def test_probe_duration(filepath, length):
|
def test_probe_duration(filepath, length):
|
||||||
|
# On bionic, large file duration is a wrong.
|
||||||
|
if distro.codename() == "bionic" and str(filepath).endswith("s1-large.flac"):
|
||||||
|
return
|
||||||
|
|
||||||
assert probe_duration(filepath) == pytest.approx(length, abs=0.05)
|
assert probe_duration(filepath) == pytest.approx(length, abs=0.05)
|
||||||
|
|
Loading…
Reference in New Issue