Skip to content

Quality Preset Device Testing

When a user changes their quality preset, podkit compares iPod track bitrate against the current preset target to detect mismatches and re-transcode affected tracks. Detection uses a percentage-based tolerance (30% for VBR, 10% for CBR) that adapts to the encoding mode. Because encoding produces content-dependent bitrates (especially audio VBR), this detection requires real-device testing beyond what automated unit and E2E tests can verify.

Why Device Testing Is Needed

  • Audio VBR variance is content-dependent. The aac_at encoder on macOS produces bitrates that vary by track content. The percentage-based tolerance (30% for VBR, 10% for CBR) was chosen based on empirical data, but new content or encoder versions could shift the ranges.
  • Video CRF variance depends on content complexity. Video uses CRF encoding with a bitrate cap. The actual bitrate is very consistent in practice (±4 kbps observed) but could vary more with extreme content.
  • Dummy iPod bitrates are unreliable. The libgpod-based test iPods store very low bitrate values (~14-17 kbps) for short test fixtures, making automated E2E detection testing impractical. Unit tests cover the detection logic; device tests verify it end-to-end.
  • Encoder mapping correctness. The aac_at encoder uses an inverted quality scale (0=best, 14=worst) compared to the native aac encoder (5=best). This was discovered through device testing and would not have been caught by unit tests alone.

Detection Approach

Audio and video preset change detection share the same core comparison via detectBitratePresetMismatch() in upgrades.ts:

  1. Compare iPod track bitrate against the current preset’s target bitrate
  2. If the difference exceeds a percentage-based tolerance (30% for VBR, 10% for CBR), flag for re-transcoding
  3. For max preset on ALAC-capable devices, use format detection instead of bitrate comparison
  4. Ignore tracks with bitrates below a minimum threshold (default 64 kbps) to avoid false positives from short files or corrupt metadata

Audio-specific: Only lossless source tracks are checked — lossy sources (MP3, AAC) are copied as-is regardless of preset.

Video-specific: All videos are transcoded, so all existing videos are checked. Videos needing re-transcoding are removed and re-added (no user data to preserve).

Observed Ranges

Audio (aac_at VBR on macOS)

Measured across CHVRCHES, Foals, and Mk.gee (44 tracks, diverse genres):

PresetTargetaac_at -q:aObserved rangeAverage
low128 kbps6111-161 kbps139 kbps
medium192 kbps4154-225 kbps189 kbps
high256 kbps2212-305 kbps253 kbps

The max preset produces ALAC on devices that support it, otherwise falls back to the same quality as high.

Adjacent audio presets (e.g., medium and high) have overlapping VBR ranges:

  • Jumps of 2+ preset levels (e.g., low to high) are always detected
  • Single-step transitions between adjacent VBR presets may miss some tracks in the overlap zone
  • CBR encoding (encoding = "cbr") produces exact bitrates and all preset changes are reliably detected

Video (H.264 CRF + bitrate cap)

Measured on iPod Video 5th Gen with 5 movie clips (varied content):

PresetTarget (5G)Observed rangeAverage
low396 kbps399-400 kbps399 kbps
medium496 kbps499-500 kbps500 kbps
high728 kbps731-734 kbps733 kbps
max896 kbps900-903 kbps902 kbps

Video bitrates are very consistent because CRF + bitrate cap produces predictable output. All adjacent transitions are reliably detected.

Video Preset Spacing by Device

DevicelowmediumhighmaxMin gap
iPod Classic1096162821282660500 kbps
iPod Video 5G396496728896100 kbps
iPod Nano 3G+396496728896100 kbps

The percentage-based tolerance (30% VBR, 10% CBR) works for all device profiles. iPod Classic has very large gaps (500+ kbps). iPod Video 5G/Nano have a minimum gap of 100 kbps (medium to low), which is well within detection range.

Test Methodology

Audio Test Setup

  1. Create a local test collection with FLAC files from 3+ albums across different genres (electronic, rock, indie). Different genres produce different VBR bitrates for the same quality setting.

  2. Create a test config pointing at the local collection:

Terminal window
mkdir /tmp/podkit-preset-test
cp -r "/path/to/Artist1/Album" /tmp/podkit-preset-test/
cp -r "/path/to/Artist2/Album" /tmp/podkit-preset-test/
cp -r "/path/to/Artist3/Album" /tmp/podkit-preset-test/
cat > /tmp/podkit-preset-test-config.toml << 'EOF'
[music.test]
path = "/tmp/podkit-preset-test"
[devices.myipod]
volumeUuid = "YOUR-UUID-HERE"
quality = "low"
artwork = true
[defaults]
music = "test"
device = "myipod"
EOF
  1. Clear the iPod by syncing an empty directory with --delete, then sync the test collection.

Audio Stress Test Sequence

StepActionExpected result
1Sync at lowAll tracks added, ~112-163 kbps
2Change to high, dry-runAll tracks: preset-upgrade
3Sync at highRe-transcoded to ~212-305 kbps
4Dry-run at high0 updates (idempotent)
5aNon-ALAC device: Change to max, dry-run0 updates (max = same as high on non-ALAC devices)
5bALAC-capable device: Change to max, dry-runAll tracks: preset-upgrade (re-transcode to ALAC)
6bSync at max on ALAC deviceRe-transcoded to ALAC (lossless)
7bDry-run at max on ALAC device0 updates (idempotent)
8Change to low, dry-runAll tracks: preset-downgrade
9Sync at lowRe-transcoded to ~112-163 kbps
10Dry-run at low0 updates (idempotent)
11--skip-upgrades0 updates (suppressed)
12Change to encoding = "cbr" at low0 updates (same target bitrate)
13Change to high with encoding = "cbr"All tracks: preset-upgrade

Video Test Setup

  1. Prepare test clips — slice a movie into 5 × 2-minute segments for varied content:
Terminal window
mkdir /tmp/podkit-video-test
for i in 1 2 3 4 5; do
START=$(( (i - 1) * 1200 + 60 ))
ffmpeg -ss "$START" -i "/path/to/movie.mkv" -t 120 -c copy \
"/tmp/podkit-video-test/clip-$i.mkv"
done
  1. Create a video test config:
Terminal window
cat > /tmp/podkit-video-test-config.toml << 'EOF'
[video.test]
path = "/tmp/podkit-video-test"
[devices.myipod]
volumeUuid = "YOUR-UUID-HERE"
videoQuality = "low"
[defaults]
video = "test"
device = "myipod"
EOF

Video Stress Test Sequence

StepActionExpected result
1Sync at lowAll clips added
2Change to medium, dry-runAll clips: re-transcode
3Sync at mediumRe-transcoded
4Dry-run at medium0 changes (idempotent)
5Change to high, syncRe-transcoded
6Dry-run at high0 changes (idempotent)
7Change to max, syncRe-transcoded
8Dry-run at max0 changes (idempotent)
9Change to low, syncRe-transcoded
10Dry-run at low0 changes (idempotent)

Key Assertions

At each step, verify:

  • Track/video count never changes — preset changes produce upgrades (audio) or remove+re-add (video), not net adds/removes
  • Same-preset re-runs are idempotent — 0 updates/changes when quality hasn’t changed
  • --skip-upgrades suppresses audio preset changes
  • Bitrate distribution matches expected range for the active preset
  • No infinite loops — re-transcoding at the same preset produces bitrates within tolerance

Running with JSON Output

Use --dry-run --json to inspect audio planned operations:

Terminal window
podkit --config /tmp/podkit-preset-test-config.toml sync --dry-run --json

Check plan.updateBreakdown for preset-upgrade and preset-downgrade counts. Check plan.tracksExisting to verify idempotency.

Test Results (March 2026)

Audio

Tested on iPod Video 5th Generation (60GB) with 44 FLAC tracks (CHVRCHES, Foals, Mk.gee):

TransitionDetectedMissedNotes
low → high44/440100% detection
high → high0/44Idempotent
high → low44/440100% detection
low → low0/44Idempotent
low → high (skip-upgrades)0/44Correctly suppressed
low VBR → low CBR0/44Same target bitrate
low → high CBR44/440100% detection

Video

Tested on iPod Video 5th Generation (60GB) with 5 movie clips (Hot Tub Time Machine, varied scenes):

TransitionDetectedIdempotent
low → medium5/5
medium → high5/5
high → max5/5
max → low5/5
low → low0/5

All adjacent video transitions detected. Video CRF + bitrate cap produces highly consistent bitrates with no overlap between presets.

See Also