24

How can I extract the aac audio from an mp4 file?

I tried with ffmpeg and -acodec copy but if i use mp4 as output it will still encode the video and I get the same file size.

If I use m4a as output it will somehow still encode the video and I get almost the same filesize.

With aac as output I can't open the file in puddletag although the file size suggests the video was stripped

Thanks in advance

3 Answers3

38

I finally found the solution myself in using mp4 or m4a as output format and adding -vn to prevent also copying the video.

ffmpeg -i input.mp4 -vn -c:a copy output.m4a

(Source: https://superuser.com/a/706622/180675)

Seems simple now :]

Fast and lossless stripping

Martin Thornton
  • 5,996
  • 12
  • 32
  • 43
5

Another option:

MP4Box -add infile.mp4#audio outfile.m4a

MP4Box is part of the gpac package.

ʇsәɹoɈ
  • 964
  • 9
  • 12
1

Just for fun, you can also do it by using vlc. The script below strips all *.mp4 files in the current directory to *.m4a. There are some error messages which can be ignored.

#!/bin/bash

quote=\"  
executable="/usr/bin/vlc"
argument3=vlc://quit

#parameters
accessvalue=file
muxvalue=mp4

for x in *.mp4; do
    inputname="${x}"
    strippedname=${x%.mp4}
    outputname=${strippedname}.m4a
    quote_outputname=${quote}./${outputname}${quote}
    echo ${inputname}
    echo ${quote_outputname}
    qtranscode=#transcode{vcodec=none}: # rm this commnt, cont' nxt line !!
    standard{access=$accessvalue,mux=$muxvalue,dst=${quote_outputname}}
    argument1="$inputname"
    argument2=--sout=$qtranscode
    "$executable" -I dummy "$argument1" "$argument2" "$argument3"
done
dessert
  • 40,956
oscar1919
  • 1,747
  • 14
  • 15