# FFmpeg replace-audio checklist (ToolBrivio) Pasteable gate: map video from input 0 and audio from input 1, keep `-c:v copy`, prove one audio stream and matching durations with ffprobe, then FAIL no-map old tone, dual-audio `-map 0`, short audio + `-shortest`, bad map index, and WMA2 copy. Purpose: stick a cleaned WAV/AAC track onto a finished MP4 without another video encode. Not concat. Not burn-in. Not Shorts crop. Not loudnorm deep-dive. Test basis: ToolBrivio Guide dated 2026-11-06 (Debian 13; FFmpeg/ffprobe 7.1.5-0+deb13u1). Synthetic 640x360@30 h264+aac fixture 8.000000 s / 240 frames / 1,357,399 B. Clean 880 Hz WAV 768,108 B or M4A 129,317 B. **Not a client recording.** Numbers: `/articles/ffmpeg-replace-audio-track-review.html`. Source video duration / frames / bytes: New audio codec / duration / bytes: Encode vs copy chosen: Output streams / V= A= F= / bytes: No-map FAIL checked (Y / N): Dual-audio FAIL checked (Y / N): Short+shortest FAIL checked (Y / N): Bad-map / WMA2 FAIL checked (Y / N): PASS / FAIL / HOLD: ## 1. Confirm FFmpeg ```bash ffmpeg -version | head -n 5 ``` Lab: FFmpeg 7.1.5-0+deb13u1. HOLD: Windows / macOS builds. - [ ] Version written down ## 2. Probe the finished video and the new audio ```bash ffprobe -v error -show_entries format=duration,size \ -show_entries stream=index,codec_type,codec_name,width,height,nb_frames,sample_rate,channels,duration \ -of default=nw=1 finished.mp4 ffprobe -v error -show_entries format=duration,size \ -show_entries stream=codec_type,codec_name,sample_rate,channels,duration \ -of default=nw=1 clean.wav ``` Lab: h264 640x360 30 fps + aac mono; 8.000000 s; 240 frames; 1,357,399 B. Clean WAV PCM s16le 8.000000 s / 768,108 B. Clean M4A AAC 8.000000 s / 129,317 B. - [ ] Video WxH / frames / duration / bytes recorded - [ ] New audio codec / duration / bytes recorded ## 3. Choose AAC encode vs copy WAV/PCM -> `-c:a aac -b:a 192k` (192k = our lab bitrate). Already-AAC M4A may use `-c:a copy`. Always `-c:v copy`. HOLD: player acceptance of odd muxes. - [ ] Encode vs copy chosen on purpose ## 4. Replace with exact map and -c:v copy ```bash ffmpeg -y -hide_banner -i finished.mp4 -i clean.wav \ -map 0:v:0 -map 1:a:0 \ -c:v copy -c:a aac -b:a 192k \ replaced.mp4 echo exit=$? stat -c '%s' replaced.mp4 ``` Lab WAV-AAC: 1,383,447 B; 2 streams; V=A=8.000000; video MD5 86b28f45226ab6861fd59c72b1e24813; 240 matching frames. ```bash ffmpeg -y -hide_banner -i finished.mp4 -i clean.m4a \ -map 0:v:0 -map 1:a:0 \ -c:v copy -c:a copy \ replaced-copy.mp4 ``` Lab AAC-copy: 1,356,948 B; same video hash; audio streamhash 2fc80679e4042a50034c8463d5285cf5. HOLD: GPU / NVENC. - [ ] Exit 0; bytes recorded - [ ] Both map options and `-c:v copy` present ## 5. Prove with ffprobe ```bash OUT=replaced.mp4 ffprobe -v error -show_entries stream=index,codec_type,codec_name,duration,nb_frames \ -show_entries format=duration,size,nb_streams -of default=nw=1 "$OUT" V=$(ffprobe -v error -select_streams v:0 -show_entries stream=duration -of csv=p=0 "$OUT") A=$(ffprobe -v error -select_streams a:0 -show_entries stream=duration -of csv=p=0 "$OUT") F=$(ffprobe -v error -show_entries format=duration -of csv=p=0 "$OUT") N=$(ffprobe -v error -show_entries format=nb_streams -of csv=p=0 "$OUT") echo "streams=$N V=$V A=$A F=$F" ``` Lab: streams=2; V=A=F=8.000000; WAV-AAC size 1383447; AAC-copy size 1356948. Old audio MD5 must not remain 05c194d7ec0be7ae8fd9f15e2692152f. - [ ] Exactly one video + one audio - [ ] Durations match intent - [ ] Old audio not retained ## 6. Pitfall: wrong map (silent EXIT=0) ```bash ffmpeg -y -hide_banner -i finished.mp4 -i clean.wav \ -c copy \ wrong-no-map.mp4 echo EXIT_NOMAP=$? ``` Lab FAIL: EXIT=0; old AAC MD5 retained; 1,357,368 B. ```bash ffmpeg -y -hide_banner -i finished.mp4 -i clean.m4a \ -map 0 -map 1:a -c copy \ wrong-old-plus-new.mp4 echo EXIT_DUAL=$? ``` Lab FAIL for one-track replace: EXIT=0; 3 streams; 1,485,955 B. HOLD: `-map 0:s?` subtitle keep (not tested). - [ ] Recognized no-map EXIT=0 + old audio - [ ] Recognized dual-audio EXIT=0 + nb_streams=3 ## 7. Duration gate: decide on -shortest from measured lengths ```bash ffmpeg -y -hide_banner -i finished.mp4 -i clean-short-4s.wav \ -map 0:v:0 -map 1:a:0 -c:v copy -c:a aac -b:a 192k \ short-no-shortest.mp4 ``` Lab: V=8.000000 / 240 frames; A=4.000000; 1,303,852 B. ```bash ffmpeg -y -hide_banner -i finished.mp4 -i clean-short-4s.wav \ -map 0:v:0 -map 1:a:0 -c:v copy -c:a aac -b:a 192k \ -shortest \ short-with-shortest.mp4 ``` Lab FAIL if full picture required: 4.000000 s / 120 frames / 693,102 B. ```bash ffmpeg -y -hide_banner -i finished.mp4 -i clean-long-12s.wav \ -map 0:v:0 -map 1:a:0 -c:v copy -c:a aac -b:a 192k \ -shortest \ long-with-shortest.mp4 ``` Lab: V=A=F=8.000000; 240 frames; 1,383,446 B. Without flag: container/audio 12.000000 s, video still 8.000000 s / 1,460,328 B. HOLD: player tail behavior. - [ ] Both durations written before choosing `-shortest` - [ ] Short+shortest recognized as picture truncation when unintended ## 8. Pitfall: bad map index and incompatible copy ```bash ffmpeg -y -hide_banner -i finished.mp4 -i clean.wav \ -map 0:v:0 -map 2:a:0 \ -c:v copy -c:a aac \ fail-bad-map.mp4 echo EXIT_BADMAP=$? ``` Lab FAIL: EXIT=234; `Invalid input file index: 2.` ```bash ffmpeg -y -hide_banner -i finished.mp4 -i clean.wma \ -map 0:v:0 -map 1:a:0 \ -c:v copy -c:a copy \ fail-wma-copy.mp4 echo EXIT_WMA=$? ``` Lab FAIL: EXIT=234; wmav2 not supported in container. Re-encode to AAC. PCM/FLAC copy EXIT=0 here is a quirk, not delivery advice. - [ ] Recognized EXIT=234 bad map index - [ ] Recognized EXIT=234 incompatible audio copy ## What we saw (lab) | Step | What we saw | Call | |---|---|---| | 1 | FFmpeg 7.1.5-0+deb13u1 | PASS | | 2 | 640x360; 8.000000 s; 240 frames; 1357399 B | PASS | | 3 | WAV -> AAC encode; M4A AAC may copy | PASS | | 4 | WAV-AAC 1383447 B; AAC-copy 1356948 B; video MD5 match; 240 frames | PASS | | 5 | nb_streams=2; V=A=F=8.000000 | PASS | | 6 | no-map 1357368 B old tone; dual-audio 1485955 B / 3 streams | FAIL pattern | | 7 | 4s+shortest -> 120 frames / 693102 B; 12s+shortest keeps 240 frames / 1383446 B | PASS gate / FAIL misuse | | 8 | bad map EXIT=234; WMA2 copy EXIT=234 | FAIL pattern | Evidence: `evidence/ffmpeg-replace-audio-track/` (NOTES, sizes-bytes.txt, probes, hashes, logs), 2026-11-06. ## Honest limits - Synthetic lavfi tones only. Not a real interview. - NLE timeline replace, lip sync, multi-language, subtitles, apad, GPU, player upload preview: not tested. - Deep loudnorm / SoX / burn-in / concat / Shorts: out of scope. Companion review: `/articles/ffmpeg-replace-audio-track-review.html`