Extract the sound

Problem

Extract the sound stream from an audio-visual file.

Solution

ffmpeg \
    -i input_file \
    -c:a copy \
    -vn \
    output_file

Command syntax

ffmpeg
starts the command
-i input_file
path, name and extension of the input file
-c:a copy
re-encodes using the same audio codec
-vn
no video stream (mnemonically «video no»)
output_file
path, name and extension of the output file

Discussion

Only the sound stream is copied into the output file by keeping the same audio codec as the input file.

The audio codec is specified by -codec:audio, which may be abbreviated as -c:a (or -codec:a or -c:audio). We advise to avoid the alias -acodec.


2018–07–21