Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

If one downloads videos from YouTube using youtube-dl, they get .mp4 files which are a ISO Media, MPEG v4 system, version 2.

Can these files be converted to audio-only, ideally with no quality loss?
The goal is to save space by throwing out the unneeded visual part.

share|improve this question

marked as duplicate by Maythux, souravc, BuZZ-dEE, Bruno Pereira Feb 18 '14 at 11:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

even after you convert it to mp3, I don't think the size will change see my question from yesterday… – Lynob Feb 17 '14 at 11:37
Voting to keep this open, as the answers and question here are superior, and with a slightly different focus. – belacqua Feb 17 '14 at 23:25
Voting to close. There is already a question about How to extract audio from video files. – Lucio Feb 18 '14 at 23:31

You can convert to audio only formats using youtube-dl itself, although it still downloads the video and then converts it.

To do this, use -x or --extract-audio to the command, for example:

youtube-dl -x
share|improve this answer
+1d it, totally CLI ninja trick :D – Kushal Feb 17 '14 at 7:29
"youtube-dl -f bestaudio <url>" also works – wiak Feb 22 at 21:23

You can convert existing downloaded files using ffmpeg from the command-line

ffmpeg -i "input file.mp4" -acodec copy "output file.aac"

The "acodec copy" part is the bit that doesn't change the audio stream.

share|improve this answer

enter image description here

YouTube Center is excellent user script, which works accross browsers, doesn't involve bloating your OS with ton of Youtube downloaders unless you're a strictly 320 kbps person for your audio files. Besides, you have Handbrake at your disposal which involves bit of a manual work but will do exactly what you want. :)

share|improve this answer

A command line alternative to download and immediately convert to a desired format is to send a file downloaded with cclive Install cclive to avconv with the cclive option --exec.


  1. Download video, then extract the audio track to keep the original encoding:

    cclive -f best <videolink> --exec "avconv -i '%n' -acodec copy <name>.<extension>"
    • needs <extension> to be in the same format as the source audio format (e.g. aac)
  2. Download video, then convert audio to mp3 (or any other supported audio codec):

    cclive -f best <videolink> --exec "avconv -i '%n' -acodec lbmp3lame -b:a 256k <name>.mp3"
    • will download and convert to 256 kb/s mp3.
  3. Download video, copy audio, and delete video:

    cclive -f best <videolink> --exec "avconv -i '%n' -acodec copy <name>.aac" --exec "rm '%n'"
    • will delete the downloaded video after audio extraction.

We are quite versatile to convert to any audio codec avconv can encode, and this will also work on download sites other than YouTube.

Note for cclive >= 0.7.12 in Ubuntu >= 13.10:
Option -f was replaced by option -s. Give option -s best for best available encoding, -s <ID> for any other encoding as can be listed with cclive -S <URL>.

share|improve this answer

youtube-dl --help explains how:

  Post-processing Options:
    -x, --extract-audio              convert video files to audio-only
                                     files (requires ffmpeg or avconv and
                                     ffprobe or avprobe)
    --audio-format FORMAT            "best", "aac", "vorbis", "mp3", "m4a",
                                     "opus", or "wav"; best by default
    --audio-quality QUALITY          ffmpeg/avconv audio quality
                                     specification, insert a value between
                                     0 (better) and 9 (worse) for VBR or a
                                     specific bitrate like 128K (default 5)

Also look at my answer here which describes how to download just the audio instead of first downloading the video+audio and then discarding the video which is just wasteful.

share|improve this answer

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