9

Can I use ffmpeg or another command-line tool (I recently downloaded mkvtoolnix for example) to directly extract audio into m4a files from webm videos?

I've previously been doing this 2-step process:

ffmpeg -i input.webm temp.mp4
ffmpeg -i temp. mp4 -vn -c:a copy audio.m4a

Problems are that the first command is so slow, seemingly needlessly slow as the second command completes consistently in less than a second. Also, it's a pain to have to alternate between the two different commands.

Is there a single command I can use to put the audio of a webm video in a .m4a audio file?

I am also looking for a solution for .mkv files

theonlygusti
  • 11,032
  • 11
  • 64
  • 119

1 Answers1

17

FFmpeg only writes AAC / ALAC / AC3 codec audio to M4A, normally not featured in WebM containers, so you will have to use

ffmpeg -i input.webm -vn audio.m4a
Gyan
  • 85,394
  • 9
  • 169
  • 201
  • I'm embarrassed I didn't even try this. Why does `mp4` require the `-c:a copy`? – theonlygusti Aug 21 '17 at 13:38
  • It doesn't. If the output format supports the input's audio codec, then `-c:a copy` is preferable since it skips recompressing the data. But you can always transcode. – Gyan Aug 21 '17 at 14:13