Why is my video longer than the audio with -shortest?
The command most answers give re-encodes the audio and ends a little late:
ffmpeg -loop 1 -i cover.jpg -i audio.mp3 -c:v libx264 -tune stillimage -pix_fmt yuv420p -c:a aac -b:a 192k -shortest out.mp460.00 s of audio and 61.96 to 62.44 s of picture over four runs. The overshoot changed from run to run. With -framerate 1 on the image it wrote 134 s of picture.
-shortest stops when the audio ends, but by then the video encoder already holds frames it has not written, and they still go into the file. The fix older answers give no longer runs:
ffmpeg -loop 1 -i cover.jpg -i audio.mp3 -c:v libx264 -tune stillimage -pix_fmt yuv420p -c:a aac -b:a 192k -shortest -fflags +shortest -max_interleave_delta 100M out.mp4Fails on FFmpeg 8.0 with Unable to parse option value "shortest" and writes nothing.
- Copy the audio with
-c:a copy, as in the Fast answer. It ended at 60.00 s. - Send both streams through one
-filter_complex, as in the AAC answer.anullpasses the audio through unchanged. It ended at 60.00 s, byte for byte the same file as cutting with-t 60.



