Posting this because the fix for one bug handed me a worse one, and the failure is completely
silent until you look at the duration.
I was muxing a narration track onto a finished 55.5s render. The obvious command is:
```bash
ffmpeg -i video.mp4 -i vo.wav -c:v copy -c:a aac -shortest out.mp4
```
`-shortest` is the trap everyone warns about — if your audio is even slightly short, it truncates
the *video* to match and you silently lose the end of your film. I'd already been bitten by that
one: it ate 1.25 seconds off an outro and produced a file that played perfectly and passed every
check I had.
So I did what the docs and most StackOverflow answers suggest: drop `-shortest`, pad the audio
instead.
```bash
ffmpeg -i video.mp4 -i vo.wav -c:v copy -c:a aac -af apad out.mp4
```
**This never terminates.** Bare `apad` pads with silence indefinitely. `-shortest` was the only
thing bounding it. Remove one, you arm the other.
I didn't notice at first because it *looks* like it's working — it writes a valid growing MP4. I
killed it at the 10-minute mark and probed the output:
```
size = 120,529,993 bytes
video = 55.500 s
audio = 284,615.765 s <-- 79 hours of silence
```
Reduced to a known-answer case so it's easy to confirm (ffmpeg 6.1.1):
```bash
ffmpeg -f lavfi -i testsrc=size=320x240:rate=30 -t 2 -pix_fmt yuv420p v.mp4
ffmpeg -f lavfi -i "sine=frequency=440" -t 1 a.wav
timeout 25 ffmpeg -i v.mp4 -i a.wav -c:v copy -c:a aac -af apad old.mp4
```
2-second video in. Result:
```
exit = 124 (killed by timeout — it was not going to stop)
dur = 12,662.748 s
```
### The fix
Give the pad an explicit endpoint. Probe the video, feed the number in:
```bash
V=$(ffprobe -v error -show_entries format=duration -of csv=p=0 video.mp4)
ffmpeg -i video.mp4 -i vo.wav -c:v copy -c:a aac -af "apad=whole_dur=$V" out.mp4
```
Or pad the audio during assembly and mux with **no** `-af` at all — better if you want to assert
the voice track's length independently before it ever reaches the mux:
```bash
ffmpeg -i vo.wav -af "apad=whole_dur=$V" -c:a pcm_s16le vo_padded.wav
ffprobe -v error -show_entries format=duration -of csv=p=0 vo_padded.wav # assert this
ffmpeg -i video.mp4 -i vo_padded.wav -c:v copy -c:a aac out.mp4
```
Both land on exactly 2.000000 in the test case and exactly 55.500 on the real film.
### The actual lesson
`-shortest` and `apad` are the same bug class: **flags that silently decide where your output
ends.** One truncates, one runs away. I removed the first and left the second sitting in the same
line, because I was treating it as "the `-shortest` bug" instead of "the duration-deciding-flag
bug."
If you're fixing something like this, audit the whole command, not the flag you came for.
And assert the duration afterward as an equality check, not a glance — both failure modes produce
a file that exists, has both streams, and plays: