Is there any difference between these two commands for extracting audio from a video?
ffmpeg -i input.mp4 -c copy -map 0:a output.wav
ffmpeg -i input.mp4 -vn -acodec copy output.wav
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
If your mp4 file only contains one audio track, then both commands have the same outcome.
There is at least one major difference, in the case where your mp4 contains multiple audio tracks/streams (I'm not referring to multiple channels within a stream).
The WAV container only allows for one audio track, so is you use
-map 0:a it will potentially try to copy more than one audio track over to your WAV file which will result in an error like:
Stream mapping: Stream #0:2 -> #0:0 (copy) Stream #0:3 -> #0:1 (copy) Stream #0:4 -> #0:2 (copy) Stream #0:5 -> #0:3 (copy) Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Your command that does not specify the mapping will not throw up an error, as by default, ffmpeg only outputs one track of each type if mapping is not specified.
As an aside, you do not need to specify
-vn when using
-acodec copy and specifying the WAV container, as ffmpeg will automatically not attempt to include video in WAV.