Quality of wav files using youtube-dl

I'm trying to download music from YouTube site using youtube-dl with the best quality possible. So I've tried to download as a WAV file with this command:

youtube-dl -ci -f 'bestvideo[ext=mp4]+bestaudio' -x --audio-format wav 

which produced a big WAV file (with this video, 42.3 Mo 48kHz stereo 16bit 1536kbit/s)

But when I compared with an M4A file, downloaded with:

 youtube-dl -ci -f 'bestvideo[ext=mp4]+bestaudio' -x --audio-format m4a 

The M4A file is smaller and lower quality (with this video, 12.3 Mo 48kHz stereo 441kbit/s).

Why is the WAV file better quality? And what causes the difference of file size? It is more strange that I have asked the same quality for both (-f 'bestvideo[ext=mp4]+bestaudio')

I tried downloading with bestaudio quality and converting to a M4A file:

 youtube-dl -ci -f "bestaudio" -x --audio-format m4a 

On this file, I found that the first file had a bigger size and a bigger bitrate than the second, but it probably depends on the video you choose.

Does the flag bestaudio[ext=m4a] download the bestaudio stream in M4A format, or does it take the best audio and convert it to M4A?

I'm running on Manjaro Linux.

2 Answers

As far as I know YouTube internally stores videos in MP4 format with AAC audio (.m4a suffix). If you request a .wav file youtube-dl will simply call ffmpeg in order to convert the audio track from m4a to wav. Since wav is a lossless format both files have exactly the same quality, but wav is much bigger than m4a.

I suggest using some command like the following one:

youtube-dl -ci -f "bestaudio[ext=m4a]" 

I also suggest checking the list of available formats with the -F option (uppercase F):

youtube-dl -F 
1

You're confusing file size (or bit-rate) with audio quality. The MP4 audio is compressed; decompressing it to WAV format doesn't add any information (so cannot improve the quality) but does increase the file size.

Going the other way (compressing audio) does, in general, lose information, and does risk reducing perceptible quality.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like