music on atproto
plyr.fm
1#!/usr/bin/env bash
2set -euo pipefail
3
4# Clean up any previous runs
5mkdir -p sandbox/test-files
6rm -f sandbox/test-files/test.aiff sandbox/test-files/test.mp3 transcoder_output.log
7
8echo "Building transcoder..."
9cd transcoder
10cargo build --quiet
11cd ..
12
13echo "Starting transcoder..."
14export TRANSCODER_PORT=8083
15export TRANSCODER_HOST=127.0.0.1
16# We use 8083 to avoid conflict with any previous zombies on 8082
17
18./transcoder/target/debug/transcoder > transcoder_output.log 2>&1 &
19PID=$!
20echo "Transcoder started with PID $PID"
21
22# Cleanup function
23cleanup() {
24 echo "Stopping transcoder..."
25 kill $PID || true
26 wait $PID || true
27}
28trap cleanup EXIT
29
30# Wait for health check
31echo "Waiting for transcoder to be ready..."
32for i in {1..30}; do
33 if curl -s "http://127.0.0.1:8083/health" > /dev/null; then
34 echo "Transcoder is ready!"
35 break
36 fi
37 sleep 0.5
38done
39
40if ! curl -s "http://127.0.0.1:8083/health" > /dev/null; then
41 echo "Transcoder failed to start. Log output:"
42 cat transcoder_output.log
43 exit 1
44fi
45
46echo "Generating sample AIFF..."
47uv run scripts/generate_audio_sample.py sandbox/test-files/test.aiff --waveform sine --duration 2
48
49echo "Testing transcoding..."
50# Override port for the test script
51export TRANSCODER_PORT=8083
52./scripts/transcoder/test-local.sh sandbox/test-files/test.aiff sandbox/test-files/test.mp3
53
54# test-local.sh doesn't append .mp3 if output file is provided
55if [[ -f sandbox/test-files/test.mp3 ]]; then
56 SIZE=$(wc -c < sandbox/test-files/test.mp3)
57 echo "Success! generated MP3 size: $SIZE bytes"
58else
59 echo "Failure! MP3 file not created."
60 exit 1
61fi