I know that flv and mp4 files contain aac audio, while avivideo usually mp3 audio streams.

What command (avconv, ffmpeg) would extract the audio without transcoding it?

  • You might be interested in a PHP script I crafted, that I use to automatically determine the extension of the output audio file. Oct 7, 2018 at 1:37

2 Answers 2

ffmpeg -i video.mp4 -vn -acodec copy audio.aac

Here’s a short explanation on what every parameter does:

  • -i option specifies the input file.
  • -vn option is used to skip the video part.
  • -acodec copy will copy the audio stream keeping the original codec.
  • 1
    while the mp4 video contains aac audio, not mp3, is that keeping the audio stream without transcoding?
    – user32012
    Nov 28, 2014 at 9:26
  • 1
    Didn't take care of output file extension, my mistake. Updated the answer. Anyway, if you read the full answer, you will find that -acodec copy, this avoid transcoding.
    – jherran
    Nov 28, 2014 at 9:28
  • 1
    i suggest m4a (container for aac) instead of aac, because it seems that is not easy to play
    – user32012
    Nov 28, 2014 at 9:35
  • is it possible, while ussing ffmpeg or avconv, to have a command without mentioning the real names of input/output files, so that the command be used as such? (i would like to use that in a context menu action in nemo file manager)
    – user32012
    Nov 28, 2014 at 9:39
  • 1
    You might want to use a variable or something like that, but is better is you ask a question with all specific details.
    – jherran
    Nov 28, 2014 at 9:42

As a complementary answer, with a command that doesn't need the specific name of the file.

For a video containing aac audio:

ffmpeg -i "$0" -map 0:1 -c:a copy "${0%%.*}".m4a

To use in a context menu command, a form like this works:

bash -c 'ffmpeg -i "$0" -map 0:1 -c:a copy "${0%%.*}".m4a' %f 

Replace with corresponding audio format output for other video format input.

Initial source here.

You must log in to answer this question.