feat: transcode streams with ffmpeg

- FfmpegTranscoder with maxBitRate, format fallback to MP3 and timeOffset
- direct play when no transcode is required, preserving HTTP Range support
- transcoded responses are chunked audio/mpeg with process cleanup
- unit tests for policy and real ffmpeg output
- smoke test covers maxBitRate, timeOffset and format fallback
This commit is contained in:
TapTap committed 2026-11-13 12:53:06 +00:00
1 parent 722f486c3a
commit 18a1d7cd19
9 files changed
+254 -4

No files matched your search

+22
View File
@@ -208,6 +208,28 @@ fi
RANGE_STATUS="$(curl -s -o /dev/null -w '%{http_code}' -H 'Range: bytes=0-9' "$BASE/rest/stream.view?$AUTH&id=$SONG_ID")"
if [[ "$RANGE_STATUS" == "206" ]]; then pass "stream range"; else fail "stream range" "HTTP $RANGE_STATUS"; fi
TRANSCODE_STATUS="$(curl -s -D "$WORK/transcode.headers" -o "$WORK/transcoded.mp3" -w '%{http_code}' "$BASE/rest/stream.view?$AUTH&id=$SONG_ID&maxBitRate=64")"
if [[ "$TRANSCODE_STATUS" == "200" && -s "$WORK/transcoded.mp3" ]] \
&& grep -qi '^content-type: audio/mpeg' "$WORK/transcode.headers"; then
pass "stream transcode (maxBitRate)"
else
fail "stream transcode (maxBitRate)" "HTTP $TRANSCODE_STATUS, $(wc -c < "$WORK/transcoded.mp3" 2>/dev/null || echo 0) bytes"
fi
OFFSET_STATUS="$(curl -s -o "$WORK/offset.mp3" -w '%{http_code}' "$BASE/rest/stream.view?$AUTH&id=$SONG_ID&timeOffset=1")"
if [[ "$OFFSET_STATUS" == "200" && -s "$WORK/offset.mp3" ]]; then
pass "stream transcode (timeOffset)"
else
fail "stream transcode (timeOffset)" "HTTP $OFFSET_STATUS"
fi
FORMAT_STATUS="$(curl -s -o "$WORK/format.mp3" -w '%{http_code}' "$BASE/rest/stream.view?$AUTH&id=$SONG_ID&format=flac")"
if [[ "$FORMAT_STATUS" == "200" && -s "$WORK/format.mp3" ]]; then
pass "stream transcode (format fallback)"
else
fail "stream transcode (format fallback)" "HTTP $FORMAT_STATUS"
fi
DOWNLOAD_STATUS="$(curl -s -o /dev/null -w '%{http_code}' "$BASE/rest/download.view?$AUTH&id=$SONG_ID")"
if [[ "$DOWNLOAD_STATUS" == "200" ]]; then pass "download"; else fail "download" "HTTP $DOWNLOAD_STATUS"; fi