I went through the documentation and I can extract a wav file from an mp4 file with the command:

ffmpeg -i my_video.mp4 output_audio.wav

However, how can I control the quality of the wav file? (e.g. say I want to preserve the quality of the original audio as much as I can)


wav files typically contain uncompressed audio, and that is the default when producing a wav file using ffmpeg. So your command will already preserve the maximum quality, since there is no lossy compression (or compression of any kind) to reduce the quality.

Assuming that the original audio is compressed, you can keep the same quality without the large file size needed for uncompressed audio by just copying the original audio (without the video) to a new mp4 file:

ffmpeg -i my_video.mp4 -c copy -map 0:a output_audio.mp4

You could also re-encode it or convert it to a different audio codec, but if that codec uses lossy compression then quality will be lost.

| improve this answer | |
  • Thanks. What about sampling rate and # of bytes per second? How does ffmpeg choose these automatically? – Amelio Vazquez-Reina Jun 20 '13 at 13:10
  • The sample rate will be the same as that of the input. Because it is uncompressed, the bitrate for the wav file is simply the sample rate × sample size × number of channels. If you wanted to reduce the quality you can ask ffmpeg to resample it to a lower rate, change it to 8-bit PCM, or downmix to mono, but it does not do that by default. – mark4o Jun 20 '13 at 16:16
  • 1
    BTW you could also ask it to resample at a higher rate, but that would just increase the file size and not the quality, so there's not much point in that unless you need a specific sample rate. – mark4o Jun 20 '13 at 16:25
  • 1
    On my system with Ubuntu 14.04 I had to use -acodec copy instead of -c copy -map 0:a – Daniel Alder Nov 8 '14 at 23:20
  • 1
    This doesn't export as a wave file, and does not answer the question. – Andrew Sep 1 '17 at 20:55

Extracting Lossless/ Lossy Audio from Videos (flv / mp4 to wav / flac / mp3) Using ffmpegversion 2.3.1 in Ubuntu 14.04

Visit: http://howto-pages.org/ffmpeg/

First of all find the basic data from the source. Open the video in VLC Player. Go to

> Tools > Codec Information 
> Stream 0 (Video/ Codec/ Resolution/ Frame rate) 
> Stream 1 (Audio/ Codec/ Channel/ Sample rate)

Consider an input file (-i), such as, input.mp4 or other files- flv, avi, ...). To remove the video (-vn) and take audio out uncompressed (output.wav) at a sample rate of 44100 Hz (-ar 44100) in pulse code modulated with signed, 16 bit, little endian (-acodec pcm_s16le) samples and 2 channels (stereo) (-ac 2) use the following command.

ffmpeg -i input.mp4 -vn -acodec pcm_s16le -ar 44100 -ac 2 output.wav

Other -acodec options are mp3 flac m4a.

-acode flac converts to 24 bit file. For 16 bit sampling it should be

ffmpeg -i input.mp4 -acodec flac -bits_per_raw_sample 16 -ar 44100 output.flac

wav and flac files are larger than the mp4 file

ac3 conversion works with -acodec 3F2R/LFE -ac 6 but creats 4 dummy tracks, as checked in Audacity.

For mp3 conversion, simply use

ffmpeg -i input.mp4 -vn -acodec mp3 -ab 320k -ar 44100 -ac 2 output.mp3

One could get more options for both input and output by trying from the list obtained from command line on the terminal

$ ffmpeg -help
| improve this answer | |
  • 1
    This does not answer the question. The OP already knows how to extract the audio as a WAV file. They're asking how to control the quality—which of course is not really possible, and hence should've been the answer (like mark4o's). MP3 and FLAC are also out of the scope here. – slhck Aug 3 '14 at 17:25
  • I came to this link for a solution and when I was working around, I got some more as I have mentioned. The issue as I understood and I was also working on, as well, is "how can I control the quality of the wav file? (e.g. say I want to preserve the quality of the original audio as much as I can)". I am not a techie, but a hobbyist and new to Ubuntu and ffmpeg. $ ffmpeg -i input.mp4 also gives all the starting quality and the options can be added accordingly to get the most. – dr.murli Aug 4 '14 at 4:26
  • 1
    Unknown encoder 'pcm_s161e' please advise on how to address this. – kRazzy R Oct 23 '17 at 20:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.