Extract sound

Problem

Extract the sound stream from an audiovisual 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 is usually abbreviated as -c:a (-codec:a or -c:audio are also possible). We advise to avoid the alias -acodec.


2020-07-15