Download a YouTube video and extract the audio automatically

We had already told you about youtube-dl, a tool that by means of commands in the terminal allows us to download videos from YouTube and then view them offline, comfortably.

Happens that dmacias Some time ago he made a script which does exactly what the title of the post says:

  1. Download a YouTube video
  2. Extract the audio from that video

For the script to work you need to have installed youtube-dl:

On Ubuntu and derivatives:

sudo apt-get install youtube-dl

In ArchLinux or derivatives:

sudo pacman -S youtube-dl

Now we move on to install ffmpeg:

On Ubuntu and derivatives:

sudo apt-get install ffmpeg

In ArchLinux or derivatives:

sudo pacman -S ffmpeg

Ready, now we are going to download the script and give it execution permissions:

wget http://www.dmaciasblog.com//wp-content/uploads/2013/09/yoump3

chmod +x yoump3

Ready!

Now, to work with it, that is, to download the audio of a YouTube video, we obviously need to know which YouTube video is not? Take for example this video: Storytime, Nightwish

We execute the script and as the first parameter we pass the URL of the video to it:

./yoump3 http://www.youtube.com/watch?v=4Hlw2xHOXAI

Halfway through the process, it will ask us the name we want to give the file, has to be a name WITHOUT spaces.

And ready!

By the way, if it shows you any error that it (the script) cannot find youtube-dl in / usr / local / bin / youtube-dl, you should make a symbolic link from the path of your youtube-dl to where you indicate , that is:

sudo ln -s /usr/bin/youtube-dl /usr/local/bin/

The end!

This is a slightly more automatic way to extract the audio, although of course, you can always download the video yourself and then extract the audio with your preferred application. This solution, although it can be improved, for example, support for spaces in the name (fixable with quotes in the script), it becomes almost a YouTube to MP3 converter Like the many that there are on the internet for Windows, of course, we run ours from the terminal, it will consume less, we will know exactly how it works, etc 🙂

Thank you very much to dmacias by script.

I hope it will be you useful.

YouTube


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   come out19 said

    (Y)

  2.   Dark purple said

    It is much easier to use JDownloader or DownloadHelper (for Firefox the latter) ...

  3.   babel said

    I use Download Helper, but it is always good to know that there are more tools than one uses.

  4.   Eduardo said

    I don't need programs to download from youtube.
    I just do it like this:
    -Using the Youtube HTML5 player, I right click on the video.
    -I select «Inspect element»
    -Inside the HTML tree, I select the tag where the video that is playing is located, and I go to the "src" property.
    -There is the direct link to the video file. I just copy that link and open it in another tab.
    -I press Ctrl + S (save as) and select the folder where I want to download the video. Or you can also paste that link together with the wget command, for which we use the console. and Voilá.

    1.    KZKG ^ Gaara said

      Basically that is what youtube-dl does, it also parses the html to get the title of the video and put that title of the file name.

  5.   dmacias said

    Thanks for the mention mate.
    Regarding what is very improvable, you have fallen short, it is very very very improvable xD since I did it with the intention of showing some new GNU / linuxeros that I reconverted from Windowscrismo that with only a few minutes of keyboard we can manage a "little program" for our specific needs without loading our heaviest program systems so that we then use 10% of its options, because here is that 10% only that we will use.

    Since you mention it, I will edit it to be able to give it the name with spaces, which makes me blush the vagueness 😛

    Another small note, if you place the script in the / usr / local / bin folder and give it the execution permissions there, it will be enough to put in the terminal yoump3 "address" without having to go to the script folder and launch it with ./ For simple convenience, just download it directly at the site where we want.

    All the best

  6.   darkar said

    Good information

  7.   mono said

    Friend, an interesting way to do it, it is always good to have several alternatives to do something, but, as indicated above, it is much easier to do it with videodownloadhelper (firefox extension), it is easy to install and to extract the audio also use ffmpeg.

    Take a look if you want:
    https://addons.mozilla.org/es/firefox/addon/video-downloadhelper/?src=hp-dl-mostpopular

  8.   let's use linux said

    Do you also like Nightwish? I was listening to him a couple of years ago ... I've already lost track of him ...
    Likewise, the audio is RE bad in that video.
    Apart from that, great contribution!
    Hug! Paul.

    1.    KZKG ^ Gaara said

      Nightwish since Tarja left changed a lot, with Anette it was not the same ... now they changed Florr (or whatever it is written), we'll see 🙂

      About the audio… well, it's an example that honestly, I looked for a video and voila, I didn't even check the audio quality hahaha

      regards

  9.   John said

    I use clipgrab, you give it the address of the video you want to download from YouTube and it gives you options in which format you want it, both audio and video. I think it is not complicated.

  10.   Akira kazama said

    Just yesterday I was trying to use it, but with almost all the links I was trying to convert, it showed me the following error:

    Encrypted signatures detected.
    ERROR: unable to download video

    I ended up using one of many websites that convert YouTube links to MP3. Pity.

  11.   adr14n said

    The latest versions of youtube-dl have the option to extract the audio using the following parameters:

    youtube-dl -x --audio-format mp3

    Regards!

  12.   Bones said

    once upon a time there was a terminal that said:

    »Ffmpeg version 0.8.9-6: 0.8.9-0ubuntu0.13.10.1, Copyright (c) 2000-2013 the Libav developers built on Nov 9 2013 19:09:46 with gcc 4.8.1
    *** THIS PROGRAM IS DEPRECATED ***
    This program is only provided for compatibility and will be removed in a future release. Please use avconv instead. »

    And I end up with a 0 mega file ... happily ever after

  13.   rat kill said

    Minitube is also good and more comfortable
    regards

  14.   jecale47 said

    Hello, I did everything with zypper because I have OpenSuse and at that time I downloaded the example, without problem, but now I don't know what the script is and this appears to me: bash: ./yoump3: The file or directory does not exist.

  15.   biker said

    if you know that youtube-dl itself has an option to extract audio, right?
    $ youtube-dl --help
    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)
    –Recode-video FORMAT Encode the video to another format if necessary
    (currently supported: mp4 | flv | ogg | webm)
    -k, –keep-video keeps the video file on disk after the post-
    processing; the video is erased by default

    I don't think I need a separate script ..

  16.   Carlos Carcamo said

    Excellent, I've been looking for something like this for days!

  17.   phorious said

    Thank you so much!

  18.   Nebuchadnezzar said

    $ youtube-dl –extract-audio (or -x also works) –audio-format mp3 (vorbis also or mp4 and others) –audio-quality 129k (or 192 320 64 32) Video URL
    Only without the need for any external script does the same.

  19.   c4explosive said

    Very good script, very useful, precise and simple.
    -------------------

    Here is a link with a similar and a little more complex script that you download and give the option to convert it into mp3 and 3gp formats.
    https://github.com/c4explosive/tubecprt

  20.   cuervo291286 said

    someone knows why I get this at the end:

    *** THIS PROGRAM IS DEPRECATED ***
    This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
    * 4Hlw2xHOXAI *: No such file or directory
    rm: cannot delete "* 4Hlw2xHOXAI *": The file or directory does not exist
    Finished